Converts a number of bytes into human readable format.
Paramètres
string $bytes: Number to convert into a more human readable format.
int $precision: Number of decimals to output.
Return value
string Human readable format of the bytes.
1 call to advagg_mod_admin_byte2human()
- advagg_mod_admin_settings_form dans advagg_mod/
advagg_mod.admin.inc - Form builder; Configure advagg settings.
Fichier
-
advagg_mod/
advagg_mod.admin.inc, line 801
Code
function advagg_mod_admin_byte2human($bytes, $precision = 0) {
$units = array(
'',
'K',
'M',
'G',
'T',
);
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= 1 << 10 * $pow;
$output = ceil(round($bytes, $precision + 2) * 10) / 10;
return $output . '' . $units[$pow];
}