Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP number_format()函数_Php - Fatal编程技术网

PHP number_format()函数

PHP number_format()函数,php,Php,我正试图用下面的方式格式化我的号码 12,34,56,789.00 我试过了 number_格式($row{'money'},2,“.”,“,”) 我越来越 123,456,789.00 这不是我想要的。那么,如何做到这一点??(12,34,56789.00)只需使用名为 仅当系统具有strfmon功能时,才定义money_format()函数。例如,Windows没有,因此在Windows中未定义money_format() 因此,您可以使用以下php代码: setlocale(LC_A

我正试图用下面的方式格式化我的号码

12,34,56,789.00
我试过了

number_格式($row{'money'},2,“.”,“,”)

我越来越

123,456,789.00 

这不是我想要的。那么,如何做到这一点??(
12,34,56789.00

只需使用名为

仅当系统具有strfmon功能时,才定义money_format()函数。例如,Windows没有,因此在Windows中未定义money_format()

因此,您可以使用以下php代码:

setlocale(LC_ALL, ''); // Locale will be different on each system.
$amount = 123456789.00;
$locale = localeconv();
echo number_format($amount, 2, $locale['decimal_point'], $locale['thousands_sep']);

只需使用名为

仅当系统具有strfmon功能时,才定义money_format()函数。例如,Windows没有,因此在Windows中未定义money_format()

因此,您可以使用以下php代码:

setlocale(LC_ALL, ''); // Locale will be different on each system.
$amount = 123456789.00;
$locale = localeconv();
echo number_format($amount, 2, $locale['decimal_point'], $locale['thousands_sep']);

number\u format()。您请求的格式(2个数字+逗号+2个数字+逗号)不是标准格式。您必须编写自己的函数来进行分组(可能使用
money\u format()
)。您不能使用number\u格式进行分组,因为函数的目的是明确地“使用分组的千来格式化数字”。
number\u format()
方法在定义的/标准组中格式化数字(即千、百万等)。您请求的格式,2个数字+逗号+2个数字+逗号,不是标准格式。您必须编写自己的函数来进行分组(可能使用
money\u format()
)。您不能使用number\u格式,因为函数的用途是明确地“使用分组的千对数字进行格式化”。是否有效?。如果您将$amount保留为123456789(不带.00)。非常抱歉,请参考以下问题。这样,您就可以了解这个想法。是否有效?。如果您将$amount保留为123456789(不带.00)。非常抱歉,请参考以下问题。这样,您就可以了解这个想法。。