I want to take numbers as shown below and shorten them down. 5,877,210,367,380 to 5.87TR *for 5.87 trillion 5,877,210,367 to 5.87B *for 5.87 billion 5,877,210 to 5.87M *for 5.87 million 5,877 to 5.87T *for 5.87 thousand Any ideas how to perform this with php and example would be great. To late for me tonight and cant seem to wrap my head around it. Thanks, TJ
function humanSizes($bytes) { $type = array("", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"); $idx = 0; while($bytes >= 1024) { $bytes /= 1024; $idx++; } return("".round($bytes, 2)." ".$type[$idx]."bytes"); } I'm sure you can work it out similarly for trillion, million, thousand...