note 39991 added to function.filesize
| From: | silentium0 at mailcity dot com | Date: | Tue, 17 Feb 2004 20:13:35 +0000 |
| Subject: | note 39991 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65322@lists.php.net to get a copy of this message | ||
for all you coders seeking a one-liner:
function returnFileSize($sizeInBytes,$precision=2){
return ($sizeInBytes < 1024)?"$sizeInBytes bytes":round(($sizeInBytes /
pow(1024,floor(log($sizeInBytes,1024)))),$precision)." ".substr("
KMGT",log($sizeInBytes,1024),1)."b";
}
Just a remake of all other functions below, packed into one row.
I leave no guarantee that this function will be faster than anything else here, it is very possible
that it will be slower.
Like I said, its a one-liner no more no less...
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39991
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39991&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39991&report=yes
Search -- http://master.php.net/manage/user-notes.php