What does "6k views" mean and how can I format this number in PHP?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
In
6k
, thek
meanskilo
(i hope you know) which equals to6000
. You replace the thousand figure withk
, that's it. Hope that helps :)or if the
$number="6k";
'6k views' on StackOverflow refers to the number of views a question has received. It means 6000 views.
If you're looking to format a similar style number in php then try something like
Obviously you can add cases for m, g and t views if desired.
k is the abbreviation for the Kilo prefix and means thousand. So 6k means six thousand.
You can format a number in such a way with the following function using division:
Or using logarithm base 10 and exponentiation: