Build a new list from existing with javascript or php
I want to create breadcrumbs with dropdown menu for my site
I need to convert this existing list into
<div class="menu">
<ul>
<li>
<a href="#">GRANDPARENT A</a> <!-- comment -->
<ul>
<li><a href="#?AAA">PARENT A</a> <!-- comment -->
<ul>
<li><a href="#">CHILD A</a>
</li>
<li><a href="#">child b</a>
</ul>
</li>
<li><a href="">parent b</a>
</li>
</ul>
</li>
<li>
<a href="#">grandparent b</a> <!-- comment -->
</li>
</ul>
</div>
this format (including adding a class to the current path):
<li>
<a href="#">GRANDPARENT A</a> <!-- comment -->
<ul>
<li>
<a href="#">grandparent b</a> <!-- comment -->
</li>
</ul>
</li>
<li><a href="#?AAA">PARENT A</a> <!-- comment -->
<ul>
<li><a href="">parent b</a>
</li>
</ul>
</li>
<li><a href="#">CHILD A</a>
<ul>
<li><a href="#">child b</a>
</li>
</ul>
</li>
I tried a lot but could not get a good result. I would prefere php but could only get next to a solution in js.
Answer
Solution:
That is the dirty solution I have found up to now (it also filters out links where