Php 如何以逻辑方式在数字中添加逗号

Php 如何以逻辑方式在数字中添加逗号,php,Php,我不知道如何转换数字。 number\u format()对我没有帮助。 这就是我想做的 from 1 to 0,01 from 12 to 0,12 from 1234 to 12,34 from 12345 to 123,45 from 123456 to 1.234,56 from 1000000 to 10.000,00 from 123456789 to 1.234.567,89 etc. 谢谢:)首先除以100,然后可以使用: 首先除以100,然后可以使用: 前两个不太合理,如果这

我不知道如何转换数字。
number\u format()
对我没有帮助。 这就是我想做的

from 1 to 0,01
from 12 to 0,12
from 1234 to 12,34
from 12345 to 123,45
from 123456 to 1.234,56
from 1000000 to 10.000,00
from 123456789 to 1.234.567,89
etc.

谢谢:)

首先除以
100
,然后可以使用:


首先除以
100
,然后可以使用:


前两个不太合理,如果这是您的问题,您可以用-?x/100除以100,然后使用
数字\u格式
?但为什么呢?前两个并没有真正的意义。如果这是你的问题,你可以用-?x/100除以100,然后使用
数字格式
?但是为什么?打败我<代码>数字格式(123456789/100,2,“,”,“)我已经编辑了函数定义,因为我觉得这让事情变得更清楚了<代码>数字格式(123456789/100,2,“,”,“)我已经编辑了函数定义,因为我觉得这会让事情变得更清楚
$number = 1;
echo number_format($number / 100, 2, ",", "."); // 2 decimals, "," and "." as seperators
// gives 0,01