Re: if statement

From: Date: Tue, 30 Sep 2003 16:28:02 +0000
Subject: Re: if statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-164422@lists.php.net to get a copy of this message
if(in_array($k2b, $array)) { ... Steve Buehler wrote:
I have an "if" statement that I would like to make a little bit more generic. This is how the statement looks now. if($k2b=="/etc/bind/options.conf.wp" || $k2b=="/etc/bind/rndc.conf.wp" || $k2b=="/etc/bind/keys.conf.wp"){
    do this1
}else{
    do this2
} 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
} I think that might make enough since to see if someone can help me on this. This would be real nice for me in use in a lot of scripts. Thanks Steve PHP / MySQL


« previous php.general (#164422) next »