ID: 38453
Updated by: [EMAIL PROTECTED]
Reported By: z_rules55 at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
PHP Version: 5.1.4
New Comment:
There is absolutely no need for a function that can be implemented in 3
lines of PHP code.
Previous Comments:
------------------------------------------------------------------------
[2006-08-14 15:29:57] z_rules55 at hotmail dot com
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 this bug report at http://bugs.php.net/?id=38453&edit=1