如何格式化数字只有两位小数?

goo*_*ing 13 php mysql

我希望实数可以是例如12.92,但不是12.9241.有可能这样做吗?

Joh*_*lla 23

在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
Run Code Online (Sandbox Code Playgroud)