Page 1 of 1

regex search through array?

Posted: Thu Aug 09, 2007 1:45 pm
by tomprogers
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.

Posted: Thu Aug 09, 2007 1:51 pm
by superdezign
Technically, array_search() loops as well. There aren't many different ways to traverse an array. ;)

Posted: Thu Aug 09, 2007 1:55 pm
by tomprogers
Gah. Okay. Thanks.