note 109515 deleted from function.in-array by cmb
| From: | cmb@php.net | Date: | Mon, 08 Jun 2015 17:55:26 +0000 |
| Subject: | note 109515 deleted from function.in-array by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202773@lists.php.net to get a copy of this message | ||
Note Submitter: q*bist
----
version of in_array that searches by regular expression. Don't forget to preg_quote() your
search term.
<?php
function in_array_match($regex, $array) {
if (!is_array($array))
trigger_error('Argument 2 must be array');
foreach ($array as $v) {
$match = preg_match($regex, $v);
if ($match === 1) {
return true;
}
}
return false;
}
?>