<?php /*
* format_filesize choses the best human readable unit for $bytes returns a formatted string
* Updates, documentation and examples: http://daniel.lorch.cc/projects/format_filesize/
*
* Revision: 1.00
*/
function format_filesize($bytes, $decimals = 1)
{
$units = array(
'1152921504606846976' => 'EB', /* Exa Byte 10^18 */
'1125899906842624' => 'PB', /* Peta Byte 10^15 */
'1099511627776' => 'TB',
'1073741824' => 'GB',
'1048576' => 'MB',
'1024' => 'KB'
);
if($bytes <= 1024)
return $bytes . " Bytes";
foreach($units as $base => $title)
if(floor($bytes / $base) != 0)
return number_format($bytes / $base, $decimals, ".", "'") . ' ' . $title;
}
?>
|
|