Re: IF statement help
| From: | Steve Cayford | Date: | Fri, 28 Sep 2001 18:35:27 +0000 |
| Subject: | Re: IF statement help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69206@lists.php.net to get a copy of this message | ||
Or maybe:
switch ($key) {
"control1": "control2": "control3":
"control4": "control5": "control6":
"control7": "control8": "control9":
// do something;
break;
default:
// do something else;
}
Hmm. Not much smaller though.
-Steve
On Friday, September 28, 2001, at 12:48 PM, Chesley A Windon wrote:
Hi:
I have a script with an IF statement that has to check for several control
commands in a single comparison (see below). If any one of the control
commands are present, I will call a function. If none of the commands are
present, I will call a different function.
My question is: Is there a way to accomplish the same thing without having
this large of an IF statement comparison?
if (($key=="control1") || ($key=="control2") || ($key=="control3") ||
($key=="control4") || ($key=="control5") || ($key=="control6") ||
($key=="control7") || ($key=="control8") || ($key=="control9")) {
// do something;
} else {
// do somthing else;
}
Thanks,
Chesley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net