0

我有这个功能:

money_format("%!n", $number);

这将输出:2200

我必须如何编辑我的函数才能拥有:2200.00 感谢您的帮助!

4

2 回答 2

2
$number=2200;
setlocale(LC_MONETARY, 'en_US');
echo money_format("%.2n", $number);    //2200.00

小提琴

PHP 格式手册

于 2014-09-03T13:57:47.117 回答
2

在货币格式中,使用 ".{numberOfDigits}" 作为分隔符后的位数:

money_format("%!.2n", $number);

或使用数字格式,因为无论如何您都不想要货币符号:

number_format($number, 2);
于 2014-09-03T14:00:26.993 回答