protected static function in_array_matches_regex($test, $patterns) { foreach ($patterns as $val) { if (@preg_match($val, null) === false) { if (strcasecmp($val, $test) === 0) { return true; } } else { if (preg_match($val, $test) === 1) { return true; } } } return false; }