note 37703 added to function.filesize

From: Date: Sun, 23 Nov 2003 17:09:17 +0000
Subject: note 37703 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-60881@lists.php.net to get a copy of this message
Probably won't get much smaller and cleaner than this one <?php function pretty_bytes ($bytes, $precision = 1) { $suffix = array ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'); $index = floor (log ($bytes + 1, 1024)); // + 1 to prevent -INF return sprintf ("%0.{$precision}f %s", $bytes / pow (1024, $index), $suffix[$index]); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.filesize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37703 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37703&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37703&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60881) next »