I have a hierarchical array path in a flat PHP array, e.g.: $path = array('fruit', 'banana', 'fresh');
I define my multidimensional array as $tree
. How would you use $path
to set/get the appropriate node in $tree
? $tree[$path] = 'blablabl';
throws an "Illegal offset error". I'm not sure how I would implode() the path to a string and use eval() to get the index. What's the most straightforward way to do this?