note 109111 added to function.bccomp

From: Date: Thu, 21 Jun 2012 04:42:54 +0000
Subject: note 109111 added to function.bccomp
Groups: php.notes 
Request: Send a blank email to php-notes+get-188729@lists.php.net to get a copy of this message
@github.com/alixaxel/phunction/ thx, it works fine (with string cast): @github.com/alixaxel/phunction/ thx, it works fine (with string cast and strict mode): <?php function _bccomp($a, $b, $operator = '=', $strict = true) { if (($strict) && !preg_match('/^[0-9]+$/i',$a)){ return false;} return version_compare(bccomp((string)$a, (string)$b), 0, $operator); } echo (_bccomp('21474836470001', '21474836470001','='))? 'true':'false', "\n"; // true - is same echo (_bccomp('21474836470001b', '21474836470001a','>'))? 'true':'false', "\n"; // false -is less echo (_bccomp('21474836470001a', '21474836470001a','>'))? 'true':'false', "\n"; // false -is greater echo (_bccomp('21474836471h', '21474836471h','='))? 'true':'false', "\n"; // false - not only in numbers with strict, because of "h" echo (_bccomp('21474836471', '21474836472','<'))? 'true':'false', "\n"; // true echo (_bccomp('214748364710', '21474836472','>'))? 'true':'false', "\n"; // true ?> ---- Server IP: 212.124.37.9 Probable Submitter: 77.183.27.9 ---- Manual Page -- http://www.php.net/manual/en/function.bccomp.php Edit -- https://master.php.net/note/edit/109111 Del: integrated -- https://master.php.net/note/delete/109111/integrated Del: useless -- https://master.php.net/note/delete/109111/useless Del: bad code -- https://master.php.net/note/delete/109111/bad+code Del: spam -- https://master.php.net/note/delete/109111/spam Del: non-english -- https://master.php.net/note/delete/109111/non-english Del: in docs -- https://master.php.net/note/delete/109111/in+docs Del: other reasons-- https://master.php.net/note/delete/109111 Reject -- https://master.php.net/note/reject/109111 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188729) next »