Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Code to check for a key inside a deep array
//deep search array for key
function multi_key_exists( array $arr, $key ){
// is in base array?
if ( array_key_exists($key, $arr) ) return true;
// check arrays contained in this array
foreach( $arr as $element ){
if( is_array($element) && multi_key_exists($element, $key) ){
return true;
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.