Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个功能:
money_format("%!n", $number);
这将输出:2200
我必须如何编辑我的函数才能拥有:2200.00 感谢您的帮助!
$number=2200; setlocale(LC_MONETARY, 'en_US'); echo money_format("%.2n", $number); //2200.00
小提琴
PHP 格式手册
在货币格式中,使用 ".{numberOfDigits}" 作为分隔符后的位数:
money_format("%!.2n", $number);
或使用数字格式,因为无论如何您都不想要货币符号:
number_format($number, 2);