regex search through array?
Posted: Thu Aug 09, 2007 1:45 pm
Is there a way to perform a regular expression search through an array without iterating and preg_match()ing?
The php.net doc for array_search says that "needle" can be a string, which sort of implies that it could be something else (which is supported by the "mixed" type next to it in the signature description). I tried using a regex, and it doesn't behave as desired.
Ideally, I'm looking for something like array_search that can take a regex. Otherwise I have to loop, which seems kind of inelegant.
Thanks.
The php.net doc for array_search says that "needle" can be a string, which sort of implies that it could be something else (which is supported by the "mixed" type next to it in the signature description). I tried using a regex, and it doesn't behave as desired.
Ideally, I'm looking for something like array_search that can take a regex. Otherwise I have to loop, which seems kind of inelegant.
Thanks.