Convert large number into short form(show 1k instead of 1,000) using php script
If you want to convert your large number figure into smaller like facebook, twitter etc. count and like just use my following simple php script.
function changeFormat($input) { $suffixes = array('', 'k', 'm', 'g', 't'); $suffixIndex = 0; while(abs($input) >= 1000 && $suffixIndex < sizeof($suffixes)) { $suffixIndex++; $input /= 1000; } return ( $input > 0 // precision of 3 decimal places ? floor($input * 1000) / 1000 : ceil($input * 1000) / 1000 ) . $suffixes[$suffixIndex]; }
Now if you want to check output use this line...
echo changeFormat(1100);
Please support us, Like us on Facebook.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment