You could do something like this:
$valuesarr = array($a,$b,$c,$d);
If (in_array($x,$valuesarr)) {
# do something
}
Or I guess even:
If (in_array($x,array($a,$b,$c,$d))) {
# do something
}
I don't know if your method or this method have better performance but
it's a little easier to read I guess.
-TG
> -----Original Message-----
> From: BOOT [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 30, 2004 11:49 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Control structure - easier way than repeating
> conditions in IF?
>
>
> Hello!
>
> Can anyone tell me if there is an easier/shorthand for:
>
> if ( ($x == $a) || ($x == $b) || ($x == $c) || ($x == $d)
> ....... ) {;}
>
>
> I understand the logic of why the following does not work:
>
> if ($x == ($a || $b || $c || $d)) {;}
>
>
>
>
> Thanks!
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php