Tuesday, May 01, 2007 Vienna 0 Comments
Logarithm to change file size string like this 1234567 one to human-readable format like 123 MB.
function formatSize($s)
{
$units = array("Bytes", "KB", "MB", "GB", "TB");
$count = count($units);
for($i = 0; $i < $count && $s >= 1024; $i++) { $s /= 1024; }
return (round($s, 2) . " " . $units[$i]);
}




