More than 1000 of the number can be formatted as 1k
e.g. 1320 conversion to 1.3k
or 13200 conversion to 1.32w
effect, in the Internet for a long time, have not found this plug-in, which God can tell me where to find, or the name of such plug-in is what, thank you ~
Reply content:
More than 1000 of the number can be formatted as 1k
e.g. 1320 conversion to 1.3k
or 13200 conversion to 1.32w
effect, in the Internet for a long time, have not found this plug-in, which God can tell me where to find, or the name of such plug-in is what, thank you ~
function test($num){ if($num < 1000) { return $num; } else if($num >=1000 && $num < 10000){ return round($num/1000,1).'k'; } else if ($num >= 10000) { return round($num/10000,2).'w'; }}echo test(1320);
= 10000) { $num = round($num / 10000 * 100) / 100 .' W'; } elseif($num >= 1000) { $num = round($num / 1000 * 100) / 100 . ' K'; } else { $num = $num; } return $num;}echo num2tring(12300); //1.23 Wecho num2tring(1200); //1.2 Kecho num2tring(200); //200
In JavaScript, the number is divided by 1000, then the result is rounded down with Math.floor, and the end is prefixed with K.
Math.floor (n/1000) + ' k ' K
PHP also has a similar usage