I have this table in my DB (I hope it's correctly showed):
+++++++++++++++++++++++++++ | id_child |--| id_parent | +++++++++++++++++++++++++++ | 5 |--| 2 | | 6 |--| 2 | | 7 |--| 4 | | 8 |--| 4 | | 9 |--| 5 | | 10 |--| 5 | | 11 |--| 9 | | 12 |--| 9 | ---------------------------
I wrote a php recursive function that create a multidimensional array from a parent passed (in this case '2'). So, if I put a print_r I obtain this result:
Array ( [5] => Array ( [9] => Array ( [11] => Array ( ) [12] => Array ( ) ) [10] => Array ( ) ) [6] => Array ( ) )
How I can obtain a structure of this type? (I exclude the first parent, 2)
(2) -5 --9 ----11 ----12 --10 -6
Thanks.