function bytestostring in TinyBrowser 7
Present a size (in bytes) as a human-readable value
Parameters
int $size size (in bytes):
int $precision number of digits after the decimal point:
Return value
string
File
- tinybrowser/
fns_tinybrowser.php, line 288
Code
function bytestostring($size, $precision = 0) {
$sizes = array(
'YB',
'ZB',
'EB',
'PB',
'TB',
'GB',
'MB',
'KB',
'B',
);
$total = count($sizes);
while ($total-- && $size > 1024) {
$size /= 1024;
}
return round($size, $precision) . ' ' . $sizes[$total];
}