note 32006 deleted from function.filesize by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 01 Sep 2004 17:32:15 +0000 |
| Subject: | note 32006 deleted from function.filesize by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75877@lists.php.net to get a copy of this message | ||
Note Submitter: anbolb at boltblue dot com
----
re a human-readable filesize function, PHP remembers the variable you set up in a for loop, so you
could just do something like this:
$type = Array ('bytes', 'kilobytes', 'megabytes',
'gigabytes');
$filesize = filesize ($filename);
for ($i = 0; $filesize > 1024; $i++)
$filesize /= 1024;
return round ($filesize, 2)." $type[$i]";