note 99333 deleted from function.filesize by aharvey
| From: | aharvey@php.net | Date: | Tue, 22 Jan 2013 00:18:17 +0000 |
| Subject: | note 99333 deleted from function.filesize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193315@lists.php.net to get a copy of this message | ||
Note Submitter: eric heudiard
----
It's very interesting but I can't stand the decimals for bytes and KB so here's
another example :
<?php
function format_size($size) {
$sizes = array(" Bytes", " KB", " MB", " GB", "
TB", " PB", " EB", " ZB", " YB");
if ($size == 0) { return('n/a'); } else {
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), $i > 1 ? 2 : 0) .
$sizes[$i]); }
}
?>