Re: IF statement help

From: Date: Sat, 29 Sep 2001 08:12:16 +0000
Subject: Re: IF statement help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-69263@lists.php.net to get a copy of this message
Hello You can se tables to perform such test. For example, you can do : $my_array=array(); $const_string="control"; $begin=1; $end=9; for($i=$begin;$i<=$end;$i++) { $my_array[]=$const_string.$i; } if (in_array($key,$my_array)) { } else { } see function in_array()...
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


« previous php.general (#69263) next »