note 88271 deleted from function.filesize by aidan

From: Date: Wed, 15 Apr 2009 17:36:51 +0000
Subject: note 88271 deleted from function.filesize by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153351@lists.php.net to get a copy of this message
Note Submitter: digitaldoener AT googlemail DOT com ---- Hi, this is my very fast version of byteConvert(). Without using costly pow() function. <?php /** * Byte converting with formated number * * @param int $bytes bytes * @return string */ function byteConvert(&$bytes){ $b = (int)$bytes; $s = array('B', 'kB', 'MB', 'GB', 'TB'); if($b < 0){ return "0 ".$s[0]; } $con = 1024; $e = (int)(log($b,$con)); return number_format($b/pow($con,$e),2,',','.').' '.$s[$e]; ?>

« previous php.notes (#153351) next »