-4
我需要在PHP中的功能来格式化像Facebook“喜欢”的数字。格式数字像Facebook“喜欢” - PHP
实施例:
12345 = 12,3ķ
123456 = 123ķ
1234567 = 1,23中号
谢谢!
我需要在PHP中的功能来格式化像Facebook“喜欢”的数字。格式数字像Facebook“喜欢” - PHP
实施例:
12345 = 12,3ķ
123456 = 123ķ
1234567 = 1,23中号
谢谢!
写一个这样做的函数!?
function format_num($n) {
$s = array("K", "M", "G", "T");
$out = "";
while ($n >= 1000 && count($s) > 0) {
$n = $n/1000.0;
$out = array_shift($s);
}
return round($n, max(0, 3 - strlen((int)$n))) ." $out";
}
好的!它帮助到我!!非常感谢你!! – 2013-03-04 15:18:16
请阅读[你有什么尝试](http://whathaveyoutried.com)?此外,明白,这是为了帮助,而不是“给我”或“我需要” – UnholyRanger 2013-03-04 14:57:24
我知道这已被问到此前,但有问题找到它。 – 2013-03-04 14:58:08
这样的事情? [如何格式化数字在PHP 1,000到1K](http://stackoverflow.com/questions/4703469/how-to-format-numbers-in-php-1-000-to-1k) – UnholyRanger 2013-03-04 15:01:10