Skip to content

Instantly share code, notes, and snippets.

@gthayer
Created March 3, 2015 19:44
Show Gist options
  • Save gthayer/b20f7d363cbc846bde68 to your computer and use it in GitHub Desktop.
Save gthayer/b20f7d363cbc846bde68 to your computer and use it in GitHub Desktop.
Recursive Array Search
//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