Created
March 3, 2015 19:44
-
-
Save gthayer/b20f7d363cbc846bde68 to your computer and use it in GitHub Desktop.
Recursive Array Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//By buddel - http://php.net/manual/en/function.array-search.php#usernotes | |
function recursive_array_search($needle,$haystack) { | |
foreach($haystack as $key=>$value) { | |
$current_key=$key; | |
if($needle===$value OR (is_array($value) && recursive_array_search($needle,$value) !== false)) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment