Re: Array wildcard?
| From: | Leif K-Brooks | Date: | Thu, 25 Apr 2002 18:13:49 +0000 |
| Subject: | Re: Array wildcard? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94608@lists.php.net to get a copy of this message | ||
on 4/25/02 1:58 PM, Miguel Cruz at mnc@stoic.net wrote:
On Thu, 25 Apr 2002, Leif K-Brooks wrote:
> Is there some array wildcard I can use? In other words, I have an array.
> Is there any wildcard function/character that will let me test to see if a
> string matches anything in that array? Thanks
http://php.net/in_array ?
miguel
One more question. Is there any way to use this with part of a string?
Example:
function checkfruitlove($string){
$fruitarray = array("apples","oranges");
if($string == "I love ".in_array($fruitarray)."!"){
$return = "I do too!";
}else{
$return = "I don't!";
}
return $return;
}
$answer = chechfruitlove("I love apples!"); //returns "I do too!"
$answer = chechfruitlove("I love oranges!"); //returns "I do too!"
$answer = chechfruitlove("I love pears!"); //returns "I don't!"