Hi all - Iām looping through structure panel field to create a boostrap accordion; trouble is I need a unique id for each accordion section. What is the best way to incrementally create an id based on the item number in the loop?
<?php
$items = $data->accordionContent()->toStructure();
foreach ($items as $item): ?>
<div class="card-header" id="headingOne">
<h2 class="mb-0">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<?= $item->sectionTitle() ?>
</button>
</h2>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<?= $item->sectionText()->html() ?>
</div>
</div>
<?php endforeach ?>
</div>
</div>
Thanks!