Add a new dimension to a multidimensional array without having the full path
<p>Apologies if my title is confusing. I have a table of categories that looks something like this:</p>

<pre><code>ID, Name,    Parent
1, Cat1,     0
2, Cat1_1,   1
3, Cat1_2,   1
4, Cat2,     0
5, Cat2_1,   4
6, Cat2_1_1, 5
</code></pre>

<p>I am trying to get this into a multidimensional array so that the category tree is available in its correct format for display purposes etc.</p>

<p>I am writing a recursive function (inside a class), that writes each level of the category tree to a class variable. My problem is that once I get down past the second level, I loose the ability to reference the class var in order to create the current categories children.</p>

<p>I can get a string representation of the array path, but is there a way that I can then evaluate that to give me access to the correct level of the array...</p>

<p>by example:</p>

<pre><code>$path_string = "[4]['children'][5]['children']";
</code></pre>

<p>Is there some function that would allow me to then say $cat_path = $cats.$path_string so that $cat_path is pointing to the correct level of the array.</p>

<p>Sorry if this all sounds a bit confusing. Alternatively, if anyone knows of a better way to get the data (as in the table example above) into a correct multidimensional array, please let me know!</p>

<p>Thanks</p>
