2010-04-20 154 views
5

哎HUYS IM计数我的表使用此代码:如何在逗号中输入逗号?

$county = mysql_query("SELECT COUNT(id) from table where type = 'application'"); 
$county = mysql_result($county, 0); 
$applications = ''.$county.''; 

这给我造成像1156563.但我希望看到它像1156563用逗号。我怎样才能做到这一点?

回答

10

number_format()应该是你所需要的

如果只有一个指定参数,数量 将无小数, 但每 组十万之间用逗号(“”)进行格式化。

<?php 
echo number_format(23124154); 

//output: 23,124,154 
+0

谢谢你的回答。这样可行! – 2010-04-20 12:57:15

+0

为什么我得到一个downvote? – 2010-04-20 13:16:13