Hi,
Apologies if my title is confusing. I have a table of categories that looks something like this:
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
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.
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.
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...
by example:
$path_string = "[4]['children'][5]['children']";
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.
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!
Thanks