Re: if statement

From: Date: Tue, 30 Sep 2003 16:38:49 +0000
Subject: Re: if statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-164423@lists.php.net to get a copy of this message
* Thus wrote Steve Buehler (steve@ibapp.com): > > What I would like to do is to have an array earlier in the script of just > the items that it is checking for so that it can be more easily changed if > I put this out as free or shareware software. Here is what it might look > like, but I know that if this is possible, it probably won't look at all > like this: > > > $array=("/etc/bind/options.conf.wp","/etc/bind/rndc.conf.wp","/etc/bind/keys.conf.wp"); > if($k2b==$array){ > do this1 > }else{ > do this2 > } Close, but not close enough :) if (in_array($k2b, $array) ) { // do this1 } http://php.net/in_array Although depending on the situation I usually set up array's of this type like this: $arr = array( '/etc/bind/options.conf.wp' => true, '/etc/bind/rndc.conf.wp' => true ); Then my condition is: if (@$arr[$k2b]) { // do this1 } Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#164423) next »