php带小数取整的方法以及取具体位数的number_format

//1.php丢弃小数部分,保留整数部分
echo intval("3.14159");
//2.php向上取整,有小数就整数部分加1
echo ceil("3.14159");
//3,php四舍五入.
echo round("3.14159");
//4,php向下取整
echo floor("3.14159");
//5,php取具体小数位数
echo number_format("3.14159",2);
//number_format() 函数通过千位分组来格式化数字。
//number_format(number,decimals,decimalpoint,separator)
echo number_format("1000000"); //1,000,000
echo number_format("1000000",2); //1,000,000.00
echo number_format("1000000",2,",","."); //1.000.000,00

php带小数取整的方法以及取具体位数的number_format》有1个想法

发表评论

邮箱地址不会被公开。 必填项已用*标注