Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put comma in counted numbers?

Tags:

php

mysql

count

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 give me result like 1156563. but I want to see it like 1,156,563 with commas. how can i do this?

like image 582
Ali Demirci Avatar asked Apr 20 '10 12:04

Ali Demirci


1 Answers

number_format() should be what you need

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
like image 161
Tom Haigh Avatar answered Sep 24 '22 16:09

Tom Haigh