narjis Posted March 9, 2012 Share Posted March 9, 2012 I am extracting an array from the database in sorted form with respect to it's parent_id. Now I have to make a sub tree of this array in such a way that related nodes would be inserted in 'pages' field. cleths->upper->shirts Link to comment https://forums.phpfreaks.com/topic/258579-array-problem/ Share on other sites More sharing options...
silkfire Posted March 9, 2012 Share Posted March 9, 2012 You're asking how to build a tree from a parent / children array. This problem has been documented many times, here's a very good tutorial. try to use the non-recursive function for efficiency. http://www.tommylacroix.com/2008/09/10/php-design-pattern-building-a-tree/ Link to comment https://forums.phpfreaks.com/topic/258579-array-problem/#findComment-1325469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.