我有这个
$example = "1234567"
$subtotal = number_format($example, 2, '.', '');
$ subtotal的返回值为
"1234567.00"
如何修改$ subtotal的定义,使其类似于"1,234,567.00"
最佳答案
下面将输出1,234,567.00
$example = "1234567";
$subtotal = number_format($example, 2, '.', ',');
echo $subtotal;
句法
string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
但我建议您使用money_format,它将数字格式化为货币字符串