PHP中number_format()函数的用法讲解
2019-04-11 09:16
911 查看
PHP number_format() 函数
实例
格式化数字:
<?php echo number_format("1000000")."<br>"; echo number_format("1000000",2)."<br>"; echo number_format("1000000",2,",","."); ?>
定义和用法
number_format()
函数通过千位分组来格式化数字。
注释: 该函数支持一个、两个或四个参数(不是三个)。
语法
number_format( _number,decimals,decimalpoint,separator_ )
实例 1
您想要返回一个价格:一个参数将对数字进行舍入(格式化为不带小数位形式),两个参数将给出您想要的结果:
<?php $num = 1999.9; $formattedNum = number_format($num)."<br>"; echo $formattedNum; $formattedNum = number_format($num, 2); echo $formattedNum; ?>
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对脚本之家的支持。如果你想了解更多相关内容请查看下面相关链接
您可能感兴趣的文章:
相关文章推荐
- PHP数字前补0的自带函数sprintf 和number_format的用法
- PHP number_format() 函数定义和用法
- PHP number_format() 函数定义和用法
- PHP数字前补0的自带函数sprintf 和number_format的用法(详解)
- PHP htmlspecialchars()函数用法与实例讲解
- PHP中md5()函数的用法讲解
- PHP substr()函数参数解释及用法讲解
- PHP number_format() 函数
- PHP number_format()函数
- PHP中explode()和implode()函数讲解和实战用法
- PHP中ltrim()函数的用法与实例讲解
- PHP中quotemeta()函数的用法讲解
- PHP 时间函数 讲解用法
- PHP htmlentities()函数用法讲解
- PHP hebrev()函数用法讲解
- PHP number_format() 函数
- PHP hex2bin()函数用法讲解
- PHP中数字千分位逗号分隔函数number_format()
- php:number_format() 函数通过千位分组来格式化数字
- php中数字格式化函数number_format解析