PHP number_format ( )

2010-4-29 杜世伟

定义和用法
该number_format ( )函数的格式了一些与分组数千人。

语法

number_format(number,decimals,decimalpoint,separator)

number
必需的。数量进行格式化。如果没有其他参数的设置,将一些不格式化小数和逗号( , )作为分隔数以千计。
decimals
任择。指定多少个小数。如果这个参数设定的数目将格式化一个点( 。 )作为小数点。
decimalpoint
任择。什么字符串指定要使用的小数点。
separator
任择。什么字符串指定要使用的千位分隔符。只有第一个字符分隔的使用。举例来说,的“ XXX ”将给予相同的输出作为“ × ” 。注意:如果这个参数是,所有其他参数是需要的。

提示和说明 注:此功能支持一个,两个,或四个参数(而不是3个) 。 例如

<?php
echo number_format("1000000");
echo "<br />";
echo number_format("1000000",2);
echo "<br />";
echo number_format("1000000",2,",",".");
?>
 
结果.
1,000,000
1,000,000.00
1.000.000,00


 

Powered by emlog 沪ICP备2023034538号-1