How to put a comma in counted numbers?

hey huys im counting my table with this code:

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

this gives me a result like 1156563. but I want to see it as 1,156,563 with commas. How can i do this?

+5
source share
1 answer

number_format() should be what you need

If only one parameter is specified, the number will be formatted without decimals, but with a comma (",") between each group of thousands.

<?php
echo number_format(23124154);

//output: 23,124,154
+10
source

All Articles