note 71049 deleted from function.ini-get by tularis

From: Date: Thu, 09 Nov 2006 17:45:28 +0000
Subject: note 71049 deleted from function.ini-get by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-119565@lists.php.net to get a copy of this message
Note Submitter: d0uglasemart1n at gma1l dot c0m 0=o 1=i Reason: useless ---- In case you are a little confused by the conversion code above it makes use of the fact that there are no breaks in the switch which allows the code to fall more than 1 case. It's a fun hack but I don't think it makes for very readable code (at least without a comment). I'd recomment something more readable like: function return_bytes($val) { $val = trim($val); switch (strtolower(substr($val, -1, 1))) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024 * 1024 * 1024; break; case 'm': $val *= 1024 * 1024; break; case 'k': $val *= 1024; break; } return $val; }

« previous php.notes (#119565) next »