本文介绍了以逗号分隔格式化价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在我的数据库中,我有像 I have to multiply these values with thousand and then format the result as price(comma separated)256.23 x 1000 = 256230 I want to show this as 256,230200.33 x 1000 = 200330 I want this as 200,33089.33 x 1000 = 89330 I want this as 89,330Currently I am using formulaecho "Price is : $".$price*1000;But how to format this, I've no idea. 解决方案 You are looking for the number_format function.$price=123456;echo number_format($price);// output: 123,456This function accepts either one, two, or four parameters (not three):If only one parameter is given, number will be formatted without decimals, but with a comma (",") between every group of thousands.If two parameters are given, number will be formatted with decimals decimals with a dot (".") in front, and a comma (",") between every group of thousands.If all four parameters are given, number will be formatted with decimals decimals, dec_point instead of a dot (".") before the decimals and thousands_sep instead of a comma (",") between every group of thousands. 这篇关于以逗号分隔格式化价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-16 21:01