$num = 4999.944444;
echo number_format($num).PHP_EOL;
5,000
echo number_format($num, 2);
4,999.94
$num = 4999.945444;
echo number_format($num).PHP_EOL;
5,000
echo number_format($num, 2);
4,999.95
number_format是4舍5入的策略。将留的小数位后面一位作为四舍五入的标准。
$num = 4999.944444;
echo number_format($num).PHP_EOL;
5,000
echo number_format($num, 1);
4,999.9
$num = 4999.954444;
echo number_format($num).PHP_EOL;
5,000
echo number_format($num, 1);
5,000.0