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

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM