note 46097 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Mon, 11 Oct 2004 10:59:18 +0000 |
| Subject: | note 46097 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78327@lists.php.net to get a copy of this message | ||
Note Submitter: Beny
----
I needed a function to get a human readable format. i created one that functions with bigger sizes.
i'm wondering what this is good for. ;-) i think this is worth a post.
<?
function human_size($size,$dec=1){
$size_names= array('Byte','KB','MB','GB',
'TB','PB','EB','ZB','YB','NB','DB');
$name_id=0;
while($size>=1024 && ($name_id<count($size_names)-1)){
$size/=1024;
$name_id++;
}
return round($size,$dec).' '.$size_names[$name_id];
}
echo human_size(15650645,2); // returns 14.93 MB
echo human_size(156503453645); // returns 145.8 GB
?>
i hope Aidan Lister doesn't remove it again as before:
http://www.google.ch/search?q=
cache:Qt9ePWLQcXgJ:php.isu.edu.tw/manual/tw/function.filesize.php human_size&hl=de