jburbage suggesting using recursion is fine, but from what I know, PHP does not support finite recursion.
And the question was about a “massive” multidimensional array.
Since "massive" offers greater depth in addition to large size, stack overflow can be used with this solution, since it is usually possible to create data structures on the heap that reach deeper than the stack can handle with recursion.
This approach is also undesirable in terms of performance in this case.
Just a recursively recursive solution for working in a loop, and you're almost there :-)
Here is the jburbage original suggested code again:
function get_val($array, $keys) { if(empty($keys) || !is_array($keys) || !is_array($array)) return $array; else { $first_key = array_shift($keys); return get_val($array[$first_key], $keys); } }
source share