Here is a handy function I found and is useful. The bytes is passed by reference, but I don't think it's really necessary.
PHP Code:
function byte_convert(&$bytes) { $b = (int)$bytes; $s = array('B', 'kB', 'MB', 'GB', 'TB'); if ($b < 0) { return '0 ' . $s[0]; } $con = 1024; $e = (int)log($b, $con); return number_format(round($b / pow($con, $e), 2), 2, '.' ,',') . ' ' . $s[$e]; }
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|