1
0
Fork 0

compat size() func

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@144 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2006-09-08 12:12:30 +00:00
parent 9c3e3d9e8b
commit ab1bf16c23
1 changed files with 4 additions and 4 deletions

View File

@ -40,16 +40,16 @@ function number_formats($a, $keys)
return $a;
}
function size($size, $suffix = '', $precision = 2)
function size($size)
{
$size = (int) $size;
if ($size < 1024)
return number_format($size, $precision) . ' ' . $suffix;
return number_format($size, 2) . ' b';
if ($size < 1048576)
return number_format($size / 1024, $precision) . ' K' . $suffix;
return number_format($size / 1024, 2) . ' K';
return number_format($size / 1048576, $precision) . ' M' . $suffix;
return number_format($size / 1048576, 2) . ' M';
}
function age($time)