Page 1 of 1

RegExp in array_search or in_array

Posted: Thu Aug 04, 2005 12:59 am
by anjanesh
Anyway to get array_search to work with RegExp ?

Code: Select all

$pattern = "/something:.*?/i";
$key = array_search($pattern, $Fields);
Thanks

Posted: Thu Aug 04, 2005 3:50 am
by josh
Use a foreach loop and eragi, break the loop when a match is found (if you only want one match), otherwise build an array of matches.

Posted: Thu Aug 04, 2005 7:01 am
by feyd
ereg are horribly slow.. preg is always the way to do regex.