note 106518 added to function.ini-get

From: Date: Tue, 15 Nov 2011 16:27:52 +0000
Subject: note 106518 added to function.ini-get
Groups: php.notes 
Request: Send a blank email to php-notes+get-184474@lists.php.net to get a copy of this message
This version of return_bytes takes care of the MB, GB, KB cases along with the M,G,K ones. Hope this is helpful! <?php public static function return_bytes ($val) { if(empty($val))return 0; $val = trim($val); preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches); $last = ''; if(isset($matches[2])){ $last = $matches[2]; } if(isset($matches[1])){ $val = (int) $matches[1]; } switch (strtolower($last)) { case 'g': case 'gb': $val *= 1024; case 'm': case 'mb': $val *= 1024; case 'k': case 'kb': $val *= 1024; } return (int) $val; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 208.251.184.86 ---- Manual Page -- http://www.php.net/manual/en/function.ini-get.php Edit -- https://master.php.net/note/edit/106518 Del: integrated -- https://master.php.net/note/delete/106518/integrated Del: useless -- https://master.php.net/note/delete/106518/useless Del: bad code -- https://master.php.net/note/delete/106518/bad+code Del: spam -- https://master.php.net/note/delete/106518/spam Del: non-english -- https://master.php.net/note/delete/106518/non-english Del: in docs -- https://master.php.net/note/delete/106518/in+docs Del: other reasons-- https://master.php.net/note/delete/106518 Reject -- https://master.php.net/note/reject/106518 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184474) next »