#38453 [NEW]: PHP could use a number_between() function

From: Date: Mon, 14 Aug 2006 15:29:57 +0000
Subject: #38453 [NEW]: PHP could use a number_between() function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100779@lists.php.net to get a copy of this message
From: z_rules55 at hotmail dot com Operating system: PHP version: 5.1.4 PHP Bug Type: Feature/Change Request Bug description: PHP could use a number_between() function Description: ------------ I think PHP could use a function to determine whether a given number is between a specified lower and upper bound, with the option to specify whether those bounds should be included. It would save people a bit of work in having to code their own function or repeatedly type "if(x < upperBound && x > lowerBound)". A (very, very quick) search through the PEAR Math packages didn't turn up what I'm thinking of. Something like the following code: Reproduce code: --------------- <?php // Returns whether or not an operand is between two // values, and can optionally do the comparison using // upper and lower bounds inclusive. function between($operand, $lower_bound, $upper_bound, $inclusive = true) { if($inclusive) { return ($operand >= $lower_bound && $operand <= $upper_bound); } else { return ($operand > $lower_bound && $operand < $upper_bound); } } ?> -- Edit bug report at http://bugs.php.net/?id=38453&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38453&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38453&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38453&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38453&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38453&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38453&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38453&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38453&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38453&r=support Expected behavior: http://bugs.php.net/fix.php?id=38453&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38453&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38453&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38453&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38453&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38453&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38453&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38453&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38453&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38453&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38453&r=mysqlcfg

« previous php.bugs (#100779) next »