note 82019 modified in function.filesize by felipe
| From: | felipe@php.net | Date: | Sat, 29 Mar 2008 16:00:39 +0000 |
| Subject: | note 82019 modified in function.filesize by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137720@lists.php.net to get a copy of this message | ||
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];
}
?>
--was--
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); $i++) $size /= 1024;
return round($size,$round).$sizes[$i];
}
?>
http://php.net/manual/en/function.filesize.php