Jay Blanchard wrote:>
You could write a function and share it with the rest of us!

function between ($var, $min, $max) { return ($var > $min && $var < $max) ? TRUE : FALSE; }

function in ()
{
if (func_num_args() < 2)
trigger_error('You must provide at least one argument for in()', E_USER_WARNING);

$haystack = func_get_args();
$needle = array_shift($haystack);

return in_array($needle, $haystack) ? TRUE : FALSE;
}


if (in('foo', 'bar', 'foobar', 'foo')) //... TRUE
if (in('foo', 'bar', 'foobar', 'baz')) //... FALSE

if (between(15, 10, 20)) //... TRUE

I'm not sure if you want >= and <= instead in between(), but you can just change it yourself.


Daniel

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to