RE: [PHP] IF statement help

From: Date: Fri, 28 Sep 2001 18:10:15 +0000
Subject: RE: [PHP] IF statement help
Groups: php.general 
Request: Send a blank email to php-general+get-69202@lists.php.net to get a copy of this message
> -----Original Message----- > From: Chesley A Windon [mailto:windon@orthus.net] > Sent: Friday, September 28, 2001 12:48 PM > To: php-general@lists.php.net > Subject: [PHP] IF statement help > > > 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")) { Would something like if (in_array($key, array("control1","control2","control3"))) work? --- Mark Roedel | "Blessed is he who has learned to laugh Systems Programmer | at himself, for he shall never cease LeTourneau University | to be entertained." Longview, Texas, USA | -- John Powell

« previous php.general (#69202) next »