SyntaxFix
Write A Post
Hire A Developer
Questions
There is also a really simple way to do this with the help of the RecursiveTreeIterator class, answered here: https://stackoverflow.com/a/37548504/2032235
RecursiveTreeIterator