我们不使用圆形
number_format($amount, 2, ".",""); //as you want the amount to be as much closer to real 27.99
但如果你真的需要使用圆形:
echo round(9.0, 0, PHP_ROUND_HALF_UP); // 9
echo round(9.1, 0, PHP_ROUND_HALF_UP); // 9
echo round(9.2, 0, PHP_ROUND_HALF_UP); //9
echo round(9.3, 0, PHP_ROUND_HALF_UP); // 9
echo round(9.4, 0, PHP_ROUND_HALF_UP); // 9
echo round(9.5, 0, PHP_ROUND_HALF_UP); // 10
echo round(9.6, 0, PHP_ROUND_HALF_UP); // 10
echo round(9.7, 0, PHP_ROUND_HALF_UP); // 10
echo round(9.8, 0, PHP_ROUND_HALF_UP); // 10
echo round(9.9, 0, PHP_ROUND_HALF_UP); // 10
echo round(27.999999997, 0, PHP_ROUND_HALF_UP); //28
echo round(27.994444, 0, PHP_ROUND_HALF_UP); // 28
通过向上或向下舍入,您可能会损失很多钱。您的购物篮将有 10 件物品,成本为 1.4 英镑,如果您有 10000 件物品,您的损失将是 4 便士,损失将是 400 英镑。