note 46097 added to function.filesize

From: Date: Wed, 29 Sep 2004 11:38:24 +0000
Subject: note 46097 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-77559@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.filesize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46097 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46097&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46097&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77559) next »