- Support show_bytes() output in parse_bytes() (#1486405)

release-0.6
alecpl 15 years ago
parent c3b676381b
commit 892af47869

@ -153,18 +153,21 @@ function parse_bytes($str)
if (is_numeric($str))
return floatval($str);
if (preg_match('/([0-9]+)([a-z])/i', $str, $regs))
if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', $str, $regs))
{
$bytes = floatval($regs[1]);
switch (strtolower($regs[2]))
{
case 'g':
case 'gb':
$bytes *= 1073741824;
break;
case 'm':
case 'mb':
$bytes *= 1048576;
break;
case 'k':
case 'kb':
$bytes *= 1024;
break;
}

Loading…
Cancel
Save