Using default ghs.php from lib, it is more precise, manages also terabytes and petabytes
This commit is contained in:
parent
d0dfd42001
commit
6b705d3b3a
1 changed files with 17 additions and 5 deletions
|
@ -1,10 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
function ghs($b) {
|
function ghs($b,$d=2) {
|
||||||
$o='';
|
$o='';
|
||||||
if (round($b/1024,1) >= 1) $o=round($b/1024,2).' KiB';
|
$pib=1125899906842624;
|
||||||
if (round($b/1048576,1) >= 1) $o=round($b/1048576,2).' MiB';
|
$tib=1099511627776;
|
||||||
if (round($b/1073741824,1) >= 1) $o=round($b/1073741824,2).' GiB';
|
$gib=1073741824;
|
||||||
if ($o=='') $o=$b.' B';
|
$mib=1048576;
|
||||||
|
$kib=1024;
|
||||||
|
if (round($b/$pib,1) >= 1)
|
||||||
|
$o=round($b/$pib,$d).' TiB';
|
||||||
|
elseif (round($b/$tib,1) >= 1)
|
||||||
|
$o=round($b/$tib,$d).' TiB';
|
||||||
|
elseif (round($b/$gib,1) >= 1)
|
||||||
|
$o=round($b/$gib,$d).' GiB';
|
||||||
|
elseif (round($b/$mib,1) >= 1)
|
||||||
|
$o=round($b/$mib,$d).' MiB';
|
||||||
|
elseif (round($b/$kib,1) >= 1)
|
||||||
|
$o=round($b/$kib,$d).' KiB';
|
||||||
|
else $o=$b.' B';
|
||||||
return($o);
|
return($o);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue