note 82165 deleted from function.round by googleguy
| From: | googleguy@php.net | Date: | Sun, 09 Dec 2012 08:24:00 +0000 |
| Subject: | note 82165 deleted from function.round by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192420@lists.php.net to get a copy of this message | ||
Note Submitter: admin at studio-gepard dot pl
----
Here is basic function I sue to round file size. It gives as output text, so it's very easy to
use it in your applications.
$SIZE is file size in MB.
function output is text.
<?php
function sizetotext($SIZE){
if ($SIZE>=1024){
$SIZE=round($SIZE/1024,2);
return $SIZE."GB";
}else{
if ($SIZE>=1){
return $SIZE."MB";
}else{
$SIZE=$SIZE*1000;
return "~".$SIZE."KB";
}
}
}
?>