note 48516 deleted from function.filesize by tularis

From: Date: Tue, 28 Dec 2004 09:17:25 +0000
Subject: note 48516 deleted from function.filesize by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82391@lists.php.net to get a copy of this message
Note Submitter: wasting dot my dot time at gmail dot com ---- Nice neat little function I wrote up that gives you size values in a more understandable way, forexample, 0.98Gb as opposed to 980Mb. It allowes for values slightly smaller than the acctual threshold. function sizeing($bytes) { if (round($bytes / 1000000000000000,2) >= 1) { return round(($bytes / (1099511627776 * 1024)),2) .'Pb'; } if (round($bytes / 1000000000000,2) >= 1) { return round(($bytes / 1099511627776),2) .'Tb'; } if (round($bytes / 1000000000,2) >= 1) { return round(($bytes / 1073741824),2). 'Gb'; } if (round($bytes / 1000000,1) >= 1) { return round(($bytes / 1048576),1).'Mb'; } if (round($bytes / 1000,1) >= 1) { return round(($bytes / 1024),1) .'kb'; } return (int)($bytes) .'b'; } ---- Reason: bad code

« previous php.notes (#82391) next »