note 20202 added to function.copy
| From: | ze_ped at hotmail dot com | Date: | Tue, 26 Mar 2002 14:47:34 +0000 |
| Subject: | note 20202 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-28224@lists.php.net to get a copy of this message | ||
A useful function that handles the file size and displays it like Windows (bytes, KB, MB, GB and
TB... don' t ask me why so much... i just felt like into it ;)
// $size is the filesize (in bytes)
function rendersize($size) {
$type = 'bytes';
if ($size > '1023') {
$size = $size/1024;
$type = 'KB';
}
if ($size > '1023') {
$size = $size/1024;
$type = 'MB';
}
if ($size > '1023') {
$size = $size/1024;
$type = 'GB';
}
if ($size > '1023') {
$size = $size/1024;
$type = 'TB';
}
// Fix decimals and stuff
if ($size < '10') $size = intval($size*100)/100;
else if ($size < '100') $size = intval($size*10)/10;
else $size = intval($size);
// Comment the following line if you want X.XX KB displayed instead of X,XX KB
$size = str_replace("." , "," , $size);
return "$size $type";
}
--
http://www.php.net/manual/en/function.copy.php
http://master.php.net/manage/user-notes.php?action=edit+20202
http://master.php.net/manage/user-notes.php?action=delete+20202
http://master.php.net/manage/user-notes.php?action=reject+20202