This is something I have avoided for the longest time......and now I need a bit of help ???
What I am trying to do is simply build a recursive array based on parent->child, the recursion comes when their is the possibility to add any number of sub-children to sub-children so on and so forth.
Array need to run
array(4) {
[12] => array(3) {
["title"] => string(7) "My Blog"
["parentId"] => string(1) "0"
["url"] => string(7) "my-blog"
}
[13] => array(3) {
["title"] => string(9) "Job Stuff"
["parentId"] => string(2) "12"
["url"] => string(9) "job-stuff"
}
[14] => array(3) {
["title"] => string(14) "More Job Stuff"
["parentId"] => string(2) "13"
["url"] => string(0) ""
}
[15] => array(3) {
["title"] => string(13) "Another Child"
["parentId"] => string(2) "12"
["url"] => string(0) ""
}
}
to become!
array(4) {
[12] => array(3) {
["title"] => string(7) "My Blog"
["parentId"] => string(1) "0"
["url"] => string(7) "my-blog"
["children"] => array(int) {
[13] => array(3) {
["title"] => string(9) "Job Stuff"
["parentId"] => string(2) "12"
["url"] => string(9) "job-stuff"
["children"] => array(int) {
[14] => array(3) {
["title"] => string(14) "More Job Stuff"
["parentId"] => string(2) "13"
["url"] => string(0) ""
}
}
[15] => array(3) {
["title"] => string(13) "Another Child"
["parentId"] => string(2) "12"
["url"] => string(0) ""
}
}
}
}
I have taken a stab at this for about half a day and come fairly close but.....it just results in failure.
Any help would be apprected thanks!