The number above one thousand can be formatted as 1 K. For example, 1320 is converted to 13200 K or to. This plug-in has not been found for a long time on the Internet, which of the following experts can tell me where to find the plug-in or what the plug-in name is? Thank you ~
The number above one thousand can be formatted as 1 k
For example, 1320 is converted to 1.3 kb.
Or 13200 to 1.32 w
Results: I have been searching for this plug-in online for a long time, and I have not found this plug-in. Which of the following experts can tell me where to find it or what the plug-in name is? Thank you ~
Reply content:
The number above one thousand can be formatted as 1 k
For example, 1320 is converted to 1.3 kb.
Or 13200 to 1.32 w
Results: I have been searching for this plug-in online for a long time, and I have not found this plug-in. Which of the following experts can tell me where to find it or what the plug-in name is? 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, divide the number by 1000, and then use Math. floor to round down the result.
Math. floor (n/1000) + 'K' k
Php also has similar usage