PHP retains two decimal places and rounds
Copy code The code is as follows:
$num = 123213.666666;
echo sprintf( "%.2f", $num);
php retains two decimal places and does not round
Copy code The code is as follows:
$num = 123213.666666;
echo sprintf("%.2f",substr(sprintf("%.3f", $num), 0, -2));
php round to the nearest integer
Copy code The code is as follows:
echo ceil(4.3); // 5
echo ceil(9.999); // 10
PHP rounding method, take integer
Copy code The code is as follows:
echo floor(4.3); // 4
echo floor(9.999); // 9
http://www.bkjia.com/PHPjc/313601.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313601.htmlTechArticlephp retains two decimal places and rounds the copy code as follows: $num = 123213.666666; echo sprintf("%.2f ", $num); php retains two decimal places and does not round. Copy the code as follows...