note 62300 deleted from function.disk-free-space by aidan
| From: | aidan@php.net | Date: | Thu, 16 Nov 2006 02:29:52 +0000 |
| Subject: | note 62300 deleted from function.disk-free-space by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-119787@lists.php.net to get a copy of this message | ||
Note Submitter: Martin Lindhe
----
blow, your code is broken. it returns 1 kilobyte as "1024 bytes"
<?
function formatDataSize($bytes) {
$units = array('bytes', 'KiB', 'MiB', 'GiB',
'TiB');
foreach ($units as $unit) {
if ($bytes < 1024) break;
$bytes = round($bytes/1024, 1);
}
return $bytes.' '.$unit;
}?>