note 109111 deleted from function.bccomp by danbrown

From: Date: Tue, 26 Jun 2012 14:01:20 +0000
Subject: note 109111 deleted from function.bccomp by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188847@lists.php.net to get a copy of this message
Note Submitter: hirnlager ---- @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 ?>

« previous php.notes (#188847) next »