php – 如何将逗号放入计数数字?

前端之家收集整理的这篇文章主要介绍了php – 如何将逗号放入计数数字?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

嘿,我用这段代码计算我的表:

$county = MysqL_query("SELECT COUNT(id) from table where type = 'application'");
$county = MysqL_result($county,0);
$applications = ''.$county.'';
@H_403_7@

这给我的结果像1156563.但我希望看到它像1,156,563逗号.我怎样才能做到这一点?

最佳答案
number_format()应该是你需要的

If only one parameter is given,number
will be formatted without decimals,
but with a comma (“,”) between every
group of thousands.

PHP
echo number_format(23124154);

//output: 23,124,154
@H_403_7@

猜你在找的MySQL相关文章