note 84652 added to function.filesize
| From: | php-manual at gone dot nl | Date: | Wed, 23 Jul 2008 21:36:40 +0000 |
| Subject: | note 84652 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-142628@lists.php.net to get a copy of this message | ||
Based on Maikels function.
Improved performance (10 - 15%) and added Doc-block
<?php
/**
* Present a size (in bytes) as a human-readable value
*
* @param int $size size (in bytes)
* @param int $precision number of digits after the decimal point
* @return string
*/
function bytestostring($size, $precision = 0) {
$sizes = array('YB', 'ZB', 'EB', 'PB', 'TB',
'GB', 'MB', 'kB', 'B');
$total = count($sizes);
while($total-- && $size > 1024) $size /= 1024;
return round($size, $precision).$sizes[$total];
}
?>
----
Server IP: 83.137.20.135
Probable Submitter: 81.18.169.45
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- https://master.php.net/note/edit/84652
Del: integrated -- https://master.php.net/note/delete/84652/integrated
Del: useless -- https://master.php.net/note/delete/84652/useless
Del: bad code -- https://master.php.net/note/delete/84652/bad+code
Del: spam -- https://master.php.net/note/delete/84652/spam
Del: non-english -- https://master.php.net/note/delete/84652/non-english
Del: in docs -- https://master.php.net/note/delete/84652/in+docs
Del: other reasons-- https://master.php.net/note/delete/84652
Reject -- https://master.php.net/note/reject/84652
Search -- https://master.php.net/manage/user-notes.php