note 71746 deleted from function.array-search by levim
| From: | levim@php.net | Date: | Mon, 24 Feb 2014 22:48:40 +0000 |
| Subject: | note 71746 deleted from function.array-search by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198670@lists.php.net to get a copy of this message | ||
Note Submitter: otto at twbc dot net
----
Unlimited depth array regular expression search, I found it useful, perhaps someone else will too.
Searches on the array values only. Key search could be easily added.
<?php
function Array_Search_Preg( $find, $in_array, $keys_found=Array() )
{
if( is_array( $in_array ) )
{
foreach( $in_array as $key=> $val )
{
if( is_array( $val ) ) $this->Array_Search_Preg( $find, $val, $keys_found );
else
{
if( preg_match( '/'. $find .'/', $val ) ) $keys_found[] = $key;
}
}
return $keys_found;
}
return false;
}
?>