The idea is to save all webpage data (title, description, open graph tags, etc...) into a database table. Of course, some of the pages are supposed to be children of other pages. For example, there should be "marketing" and "photography" under "services".
For simplification purposes, let's say that the table looks like this:
- webpageId
- title
- parentWebpageId
I need to find a way to loop through all this data, and print an HTML list using PHP:
<ul>
<li>home</li>
<li>
services
<ul>
<li>marketing</ul>
<li>photography</ul>
</ul>
</li>
</ul>
I'm trying to build a system which should be reusable, and there is no way to know how deep the recursion might go, so I need a way to always be sure I checked everything.
Using foreach loops inside one another doesn't seem like the best solution.
Thanks in advance.
