I have a foreach loop wrapped around an ul unordered list, the first li is a main topic and should be followed by items belonging to that topic.
Here is what it should look like

The word People and System are li with a class nav-header.
This is how my ul is displaying with other sample text for headers and items.

And this is the HTML output of my list
<ul class="nav nav-list">
<li class="nav-header">ProfileZ</li>
<li><a href="#MTIxfElrYXJpYW4tWW91dGg=.html">test</a></li>
<ul class="nav nav-list">
<li class="nav-header">zetaasdf</li>
<li><a href="#MTMwfFpldGFOZXdDYW1wYWlnbjI=.html">ZetaNewCampaign2</a></li>
<ul class="nav nav-list">
<li class="nav-header">zeta</li>
<li><a href="#MTMxfGFzZGZhc2Rm.html">asdfasdf</a></li>
</ul>
</ul></ul>
The ul is repeating and nesting, the php code I used to generate the list is below.
<?php foreach ($profilesResults as $profilesArray) { ?>
<ul class="nav nav-list">
<li class="nav-header"><?php echo $profilesArray->name; ?></li>
<?php
$campaignsObj = new Campaigns();
$campaignsResults = $campaignsObj->getCampaignsByProfileSideBar($accountID, $profilesArray->id);
foreach ($campaignsResults as $campaignsArray) {
?>
<li><a href="<?= $this->siteUrl() ?>campaign-rankings-<?= base64_encode($campaignsArray->id . "|" . str_replace(" ", "-", $campaignsArray->name)) ?>.html"><?php echo $campaignsArray->name ?></a></li>
<?php } ?>
<?php } ?>
</ul>
What changes should I make to get my list to display like in the first photo. Where there is only one open and close ul and the rest of the li within along with the special classed header lis?
Thanks
Just move
uldeclaration out from the first circle. It should look like this: