array_search() with preg_match?
| From: | René Fournier | Date: | Thu, 23 Jun 2005 16:42:08 +0000 |
| Subject: | array_search() with preg_match? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-217501@lists.php.net to get a copy of this message | ||
I need to search an array for a string, with a twist. E.g.:
$array = array(0 => 'this sky is blue', 1 => 'pencils are orange', 2 => 'I like green apples', 3 => 'strawberries are red');
$key = array_search('green', $array);
With the above code, nothing will be returned, but I would like it to return 2 for the key containing "green". Any suggestions?
...René