How to build a tree from a list of items and their children recursively in php?
- by k1lljoy
I have a list of items stored in the DB, simplified schema is like this:
id, parent, name
I need to generate a tree structure (in a form of a multi-dimensional array) that can be infinite levels deep. Top level items would have parent = 0. Next level down would have parent equal to the the id of the parent item, fairly straight forward.
What would be the best way to do this, while consuming as little resources as possible?