On 01 October 2004 14:05, Daniel Schierbeck wrote:
> 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; }
Don't make PHP do more work than it needs to:
return ($var > $min && $var < $max)
is quite sufficient.
>
> 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; }
return in_array($needle, $haystack)
Also, you may find array_splice($haystack, 0, 1) more efficient, since
array_shift() renumbers all the keys. ($needle = $haystack[0]; unset
$haystack[0]; would be another possibility.)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php