note 91477 added to function.filesize
| From: | nak5ive at DONT-SPAM-ME dot gmail dot com | Date: | Thu, 11 Jun 2009 17:59:06 +0000 |
| Subject: | note 91477 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156784@lists.php.net to get a copy of this message | ||
a quick way to convert bytes to a more readable format can be done using this function:
function formatBytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
----
Server IP: 64.71.164.2
Probable Submitter: 66.138.151.97
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- https://master.php.net/note/edit/91477
Del: integrated -- https://master.php.net/note/delete/91477/integrated
Del: useless -- https://master.php.net/note/delete/91477/useless
Del: bad code -- https://master.php.net/note/delete/91477/bad+code
Del: spam -- https://master.php.net/note/delete/91477/spam
Del: non-english -- https://master.php.net/note/delete/91477/non-english
Del: in docs -- https://master.php.net/note/delete/91477/in+docs
Del: other reasons-- https://master.php.net/note/delete/91477
Reject -- https://master.php.net/note/reject/91477
Search -- https://master.php.net/manage/user-notes.php