我希望实数是 12.92,而不是 12.9241。可以这样吗?
最佳答案
在 PHP 中,尝试 number_format
:
$n = 1234.5678;
// Two decimal places, using '.' for the decimal separator
// and ',' for the thousands separator.
$formatted = number_format($n, 2, '.', ',');
// 1,234.57
关于php - 如何将数字格式化为只有两位小数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1992406/