note 55663 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Wed, 09 Nov 2005 06:14:40 +0000 |
| Subject: | note 55663 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-98296@lists.php.net to get a copy of this message | ||
Note Submitter: Cory Christison
----
Actually... Now that I have had some sleep... This makes more sense:
<?php
function format_filesize( $filesize )
{
$filesize = (int)$filesize;
$units = array('B', 'KB', 'MB', 'GB', 'TB',
'PB', 'EB', 'ZB', 'YB');
$tot_units = (count($units) - 1);
$pass = 0; // set zero, for Bytes
while( $filesize >= 1024 && $pass < $tot_units )
{
$filesize /= 1024;
$pass++;
}
return round($filesize, 2) .' '. $units[$pass];
}
?>
Someone is going to get angry at me for posting so many times. If there is an admin, you may remove
my previous note.