我有一根绳子:
000000000000100并需要将其转换为:
1,00因此,这些规则是:
separator
发布于 2011-06-10 15:37:29
来自PHP Manual page on number_format
字符串number_format ( float $number,int $decimals =0,string $dec_point = '.‘,string $thousands_sep =’,‘,’)
如果希望将像123456这样的数字格式化为1234,45,请使用:
echo number_format($number / 100, 2, ",", "");如果您需要一个点作为数千个分隔符(1.234,56):
echo number_format($number / 100, 2, ",", ".");当将字符串转换为数字时,PHP会自动删除零。
发布于 2011-06-10 15:39:22
string number_format ( float $number ,
int $decimals = 0 ,
string $dec_point = '.' ,
string $thousands_sep = ',' )手册:http://php.net/manual/en/function.number-format.php
// divide by 100 to shift ones place.
echo number_format((int)'000000000000100' / 100,2,',','');https://stackoverflow.com/questions/6308687
复制相似问题