子钦加油

扩大
缩小

php number_format金钱 价格 格式处理 由分单位转换成元(保留2为小数)

/**
 * priceFormat
 * 价格格式处理
 *
 * @access public
 * @param  null
 * @since 1.0
 * @return object
 */
if(!function_exists('priceFormat')) {
    function priceFormat($price)
    {
 
       return number_format($price/100,2);
    }
}
 
 
number_format(需要转换的数字,保留小数个数,小数点符号,每三位的分隔符)
echo number_format("1000000")."<br>"; //默认显示:1,000,000
echo number_format("1000000",2)."<br>";//默认显示:1,000,000.00
echo number_format("1000000",2,".",""); //自定义显示:1000000.00

  

posted on 2019-07-30 16:14  子钦加油  阅读(1548)  评论(0编辑  收藏  举报

导航

返回顶部