Use 数字格式 http://php.net/manual/en/function.number-format.php为了这:
$number = 425000;
echo number_format( $number, 0, '', '.' );
上面的例子的意思是:格式化数字,使用0
小数位,空字符串作为小数点(因为我们无论如何都不使用小数位),并使用.
作为千位分隔符。
当然,除非我误解了你的意图,并且你想将数字格式化为具有 3 位小数的数字:
$number = 425000;
echo number_format( $number, 3, '.', '' );
上面的例子的意思是:格式化数字,使用3
小数位,.
作为小数点(默认),空字符串作为千位分隔符(默认为,
).
If the default thousands separator is good enough for you, you can just use 1:
$number = 425000;
echo number_format( $number, 3 );
1) Mind you: number_format
accepts either 1, 2 or 4 parameters, not 3.