php - 如何在计数中加上逗号?

标签 php mysql count

嘿嘿,我用这段代码来数我的 table :

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

这给我的结果类似于 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

关于php - 如何在计数中加上逗号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2675205/

相关文章:

mysql - 将 IS NOT NULL 与 COUNT 函数一起使用时得到不正确的结果 - MySQL

php - 我如何将 php 集成到 html 表中

php - PHP 混淆有必要吗?

mysql - 如何在mysql中获取最大值内的最大值?

php - 第 10 行 C : mysql_result() expects parameter 1 to be resource, php 中给出的警告 :\wamp\www\Bitev3\core\functions\users. boolean 值

mysql - 一个月内每天的帖子数

php - MySQL 只返回一个值

PHP多行表单,自动化MySQL输入

php - MySQL慢查询日志的应用程序特定数据?

Java-判断数组的位置变化