number_format() 函数用于格式化千位分组的数字。
number_format(num,decimals,decimal_pt,separator)
num - 要格式化的数字。
decimals - 指定小数位数。
decimal_pt - 用于小数点的字符串。
分隔符 - 指定用于千位分隔符的字符串。
number_format() 函数返回格式化的数字。
立即学习“PHP免费学习笔记(深入)”;
以下是一个示例 -
实时演示
<?php echo number_format("10000000"); ?>
以下是输出 -
10,000,000
让我们看另一个示例 -
现场演示
<?php echo number_format("3999.9, 2"); ?>
以下是输出 -
4,000
以上就是PHP中的number_format()函数的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号