I need help in creating a nested array using a loop.
The array should look like this,
Array
(
[0] => Array
(
[id] => 1
[text] => root
[leaf] =>
[children] => Array
(
[0] => Array
(
[id] => 2
[text] => root1
[leaf] =>
[children] => Array
(
[0] => Array
(
[id] => 3
[text] => root2
[leaf] =>
[children] => Array
(
[0] => Array
(
[id] => 4
[text] => lastchild
[leaf] => 1
)
)
)
)
)
)
)
)
The thing is I dont know how to recursivly put the child into the children field. Please help.