find items level(depth) in array;
hi im new in php and i cant find any method to find what dimension array items are in. for example:
array=>[
'name'=>'jack'
, 'age'=>'18'
, 'info'=>[
'address'=>'bla bla bla'
, 'email'=>'example@bla.com'
]
]
function findDepth($key)
{
// do something
}
$result = findDepth('email');
$result // int(2)
the array above has key named email and the email key is in second level of the array. is there any function or method or way to find this level.
I found a method that tell you how deep array is: Is there a way to find out how "deep" a PHP array is?