note 68532 deleted from function.filesize by bjori

From: Date: Tue, 01 Aug 2006 08:59:16 +0000
Subject: note 68532 deleted from function.filesize by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115393@lists.php.net to get a copy of this message
Note Submitter: sam dot nospam dot please at globalvision dot ch ---- The resize_bytes function from vladimir at malyugin dot ru displays a number with decimals if $size < 100, which is unconvenient. This one corrects that. <? function resize_bytes($size) { $count = 0; $format = array("B","KB","MB","GB","TB","PB","EB","ZB","YB"); while(($size/1024)>0.5 && $count<8) { $size=$size/1024; $count++; } $dec = (($count==0)?0:(($size<10)?2:(($size<100)?1:0))); return number_format($size,$dec,',',' ')." ".$format[$count]; } ?>

« previous php.notes (#115393) next »