note 55551 added to function.filesize
| From: | corychristison at lavacube dot com | Date: | Sat, 06 Aug 2005 23:55:47 +0000 |
| Subject: | note 55551 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93180@lists.php.net to get a copy of this message | ||
Wouldn't it be easier to do something like this?:
<?php
function format_filesize( $filename )
{
$filesize = filesize( $filename );
$units = array('B', 'KB', 'MB', 'GB', 'TB',
'PB', 'EB', 'ZB', 'YB');
$pass = 0; // set zero, for Bytes
while( $filesize >= 1024 )
{
$filesize /= 1024;
$pass++;
}
return round($filesize, 2) .' '. $units[$pass];
}
?>
Just a thought.
I wrote this to get the filesize of some log files. They are a daily log, and should not get any
bigger than a few hundred MB.
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55551
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55551&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55551&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55551&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55551&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55551&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55551&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55551&report=yes
Search -- http://master.php.net/manage/user-notes.php