note 39991 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Sun, 26 Sep 2004 00:20:17 +0000 |
| Subject: | note 39991 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77340@lists.php.net to get a copy of this message | ||
Note Submitter: silentium0 at mailcity dot com
----
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...