note 45991 deleted from function.filesize by aidan

From: Date: Sun, 26 Sep 2004 00:27:06 +0000
Subject: note 45991 deleted from function.filesize by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77350@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 ?>

« previous php.notes (#77350) next »