Blogger Information
Blog 142
fans 5
comment 0
visits 130523
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP_保留两位小数并且四舍五入_保留两位小数并且不四舍五入
php开发大牛
Original
611 people have browsed it

php保留两位小数并且四舍五入 

Php代码  

$num = 123213.666666;  

echo sprintf("%.2f", $num);

php保留两位小数并且不四舍五入 

Php代码  

$num = 123213.666666;  
echo sprintf("%.2f",substr(sprintf("%.3f", $num), 0, -2));  

php进一法取整 

Php代码 

echo ceil(4.3);    // 5  

echo ceil(9.999);  // 10

php舍去法,取整数 

Php代码  

echo floor(4.3);   // 4 

echo floor(9.999); // 9

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post