Does the PHP function in_array accept a REGEXP array as second argument ?
I couldn't find any relevant information on PHP.net
This is the code I'm currently using :
$haystack = [
"/^foo$/",
"/^bar$/",
"/^foobar$/"
];
function in_reg_array($needle, $haystack) {
foreach ($haystack as $straw)
if (preg_match($straw, $needle))
return TRUE;
return FALSE;
}
If anyone has a better solution, I'm open to suggestions.
Edit :
I can't use a single regexp with foo|bar|foobar because the haystack varies.
preg_grep('/^(foo|bar|foobar)$/",?preg_grep("/^(".implode('|',$haystack).")$/"?$haystackshould not contain/^and$/, so$haystack = ['foo', 'bar', 'foobar']