note 109625 deleted from function.ini-get by danbrown

From: Date: Fri, 10 Aug 2012 16:19:05 +0000
Subject: note 109625 deleted from function.ini-get by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190015@lists.php.net to get a copy of this message
Note Submitter: Dmitry Vinogradov ---- Here's more comprehensive function returning number of bytes from strings like max_post_size or upload_max_filesize. It handles both 'k'/'kb', 'm'/'mb', and 'g'/'gb' at the end of the string, and is case insensitive. <?php function return_bytes($val) { $val = trim($val); switch (strtolower(substr($val, -1))) { case 'm': $val = (int)substr($val, 0, -1) * 1048576; break; case 'k': $val = (int)substr($val, 0, -1) * 1024; break; case 'g': $val = (int)substr($val, 0, -1) * 1073741824; break; case 'b': switch (strtolower(substr($val, -2, 1))) { case 'm': $val = (int)substr($val, 0, -2) * 1048576; break; case 'k': $val = (int)substr($val, 0, -2) * 1024; break; case 'g': $val = (int)substr($val, 0, -2) * 1073741824; break; default : break; } break; default: break; } return $val; } ?>

« previous php.notes (#190015) next »