I am trying to generate the HTML for tree like (jsTree) out of a 2d array with no success.
I have the following array: My Array
and from this array i would like to create a tree html (ul and li) structure like:
<ul id="ParentId-0">
<li id="categoryID-1" data-parentid="1">
bla bla
<ul id="ParentId-1">
<li id="categoryID-20" data-parentid="20">
some Title
<ul id="ParentId-20">......</ul>
</li>
</ul>
</li>
<li id="categoryID-2" data-parentid="2">
second li Title
<ul id="ParentId-2">
<li id="categoryID-46" data-parentid="46">
Another Title
<ul id="ParentId-46">
<li id="categoryID-300" data-parentid="30">
And another Category
<ul id="ParentId-300"></ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
Anyone with an idea?
Edit
I've tried using DOMDocument to create the tree and it worked however it took like 40 - 50 seconds to load and i am trying to find a faster way.