【发布时间】:2017-04-27 14:59:01
【问题描述】:
如果我使用number_format 来格式化这样的数字:
$price = 1500;
echo number_format($price);
然后我得到这样的输出:1,500
如何使千位分隔符成为点而不是逗号(即,将1.500 作为我的输出)?
【问题讨论】:
标签: php
如果我使用number_format 来格式化这样的数字:
$price = 1500;
echo number_format($price);
然后我得到这样的输出:1,500
如何使千位分隔符成为点而不是逗号(即,将1.500 作为我的输出)?
【问题讨论】:
标签: php
number_format 的第三个和第四个参数分别控制用于小数点和千位分隔符的字符。所以你可以这样做:
number_format(
1500,
0, // number of decimal places
',', // character to use as decimal point
'.' // character to use as thousands separator
)
并获得"1.500" 作为您的结果。
【讨论】: