Skip to content

Instantly share code, notes, and snippets.

@ergunozyurt
Last active October 12, 2015 03:11
Show Gist options
  • Save ergunozyurt/94f32b32a1aa018c0b76 to your computer and use it in GitHub Desktop.
Save ergunozyurt/94f32b32a1aa018c0b76 to your computer and use it in GitHub Desktop.
Searches for the given key in multidimension array and returns its value
function searchArrayForKey($search,$array) {
$foundArray= array();
foreach ($array as $key => $value) {
if($key === $search)
{
$foundArray = $value;
break;
}
else
{
if(is_array($value)){
return searchSubArray($search,$value);
}
}
}
return $foundArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment