note 20202 deleted from function.copy by alindeman

From: Date: Fri, 09 May 2003 22:15:50 +0000
Subject: note 20202 deleted from function.copy by alindeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-47792@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"; }

« previous php.notes (#47792) next »