note 84034 deleted from function.filesize by aidan

From: Date: Wed, 15 Apr 2009 17:39:05 +0000
Subject: note 84034 deleted from function.filesize by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153356@lists.php.net to get a copy of this message
Note Submitter: Maikel ---- Even better! <?php function format_size($size, $round = 0) { //Size must be bytes! $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $total = count($sizes); for ($i=0; $size > 1024 && $i < $total; $i++) $size /= 1024; return round($size,$round).$sizes[$i]; } ?> Anyway, the previous post was to show how isset is better than count in performance

« previous php.notes (#153356) next »