Tag Info

Hot answers tagged


The problem of building a tree from a flat array has been solved here with this, slightly modified, recursive solution: /** * Modification of "Build a tree from a flat array in PHP" * * Authors: @DSkinner, @ImmortalFirefly and @SteveEdson * * @link http://stackoverflow.com/a/28429487/2078474 */ function buildTree( array &$elements, $parentId = 0 ) ...


I decided to write a function to build a tree of navigation menu objects. It was a fun exercise, not sure about how it exactly will be going to be useful, but that is to say nothing, because maybe it will be practical some time. Basically - and in short - it does create the tree of objects by putting children into a new children property inside the parent ...

Only top voted, non community-wiki answers of a minimum length are eligible