Hi there!
I've been going crazy trying to figure out how to solve this problem. It's really got me stumped :mad:
Essentially i want to take this sort of array:
[0] => Array
(
[id] => 1
[parent] => 0
[title] => Food
)
[1] => Array
(
[id] => 2
[parent] => 1
[title] => Fruit
)
[2] => Array
(
[id] => 3
[parent] => 1
[title] => Vegetables
)
[3] => Array
(
[id] => 4
[parent] => 2
[title] => Oranges
)
[4] => Array
(
[id] => 5
[parent] => 2
[title] => Apples
)
And order it like so:
[0] => Array
(
[id] => 1
[parent] => 0
[title] => Food
)
[1] => Array
(
[id] => 2
[parent] => 1
[title] => Fruit
)
[2] => Array
(
[id] => 4
[parent] => 2
[title] => Oranges
)
[3] => Array
(
[id] => 5
[parent] => 2
[title] => Apples
)
[4] => Array
(
[id] => 3
[parent] => 1
[title] => Vegetables
)
Notice how i'm trying to order it as if reading a tree diagram from top to bottom.
The only indication of depth I have is the "parent" field and there could be an unlimited depth of children.
Really appreciate any time anyone spends on this.