Files and Directories
|
|
|
|
<?php function format_filesize($int,$bytesstyle = false){
if ($bytesstyle != false){$bytes = $int;}
$str = " bytes";
if ($int > 1024+256){$int /= 1024; $str = " KB";}
if ($int > 1024+256){$int /= 1024; $str = " MB";}
if ($int > 1024+256){$int /= 1024; $str = " GB";}
if ($int > 1024+256){$int /= 1024; $str = " TB";}
$int2 = round(number_format($int,2),2);
if ($str != " bytes" AND $bytesstyle == 1){$str .= " (".$bytes." bytes)";}
return $int2.$str;
} ?>
|
|
|
Usage Example
|
<?php echo format_filesize(2624); // Produces '2.56 KB' echo format_filesize(364734757,1); // Produces '347.84 MB (364734757 bytes)' ?>
|
|
|
Rate This Script
|
|
|
|