note 82019 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Sat, 02 May 2009 10:33:41 +0000 |
| Subject: | note 82019 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154108@lists.php.net to get a copy of this message | ||
Note Submitter: php at wormss dot net
----
Just a small bit added in-case someone doesn't want it to go up to 'TB' and deletes
'TB' onwards but the file size is larger than 1024GB this checks to see if you have
outreached the size of $sizes
<?php
function format_size($size, $round = 0) {
//Size must be bytes!
$sizes = array('B', 'kB', 'MB', 'GB', 'TB',
'PB', 'EB', 'ZB', 'YB');
for ($i=0; $size > 1024 && $i < count($sizes) - 1; $i++) $size /= 1024;
return round($size,$round).$sizes[$i];
}
?>