I try to make a tree list in PHP from a hierarchy stored in a concatenated string in my mysql database
This my table :

and I’d like to reproduce something like this :
<ul>
<li>
<ul>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
</li>
<li></li>
</ul>
</li>
<li></li>
<li></li>
</ul>
I know I have to use a recursive function I don’t reach to do…
Maybe someone could help me
code without comments
see the usage and dataset section below to see what you need to pass and how to use these functions:
code with comments and explanation
The code to convert your items to a tree structure:
The code to convert the tree structure to a UL:
dataset:
usage:
in the interests of codegolf 😉
The following could replace my
items_to_treefunction — however it isn’t advised.