note 51319 added to function.filesize
| From: | wesman20 at hotmail dot com | Date: | Sun, 27 Mar 2005 10:30:27 +0000 |
| Subject: | note 51319 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87049@lists.php.net to get a copy of this message | ||
The human-readable conversion can be done with extreme brevity since it is a logarithmic scale. Feel
free to adjust the round() to your own personal tastes.
<?php
function getfilesize($size) {
$units = array(' B', ' KB', ' MB', ' GB', '
TB');
for ($i = 0; $size > 1024; $i++) { $size /= 1024; }
return round($size, 2).$units[$i];
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51319
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51319&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51319&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51319&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51319&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51319&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51319&report=yes
Search -- http://master.php.net/manage/user-notes.php