0
Let’s assume that I have a div inside a foreach and inside that div I have another div with an x class, but I would like that x class to be numbered with each repetition, there is this possibility?
Code example:
<?php
foreach ($list_menu as $key => $menu):
?>
<?php
if(count($menu->subMenu)):
?>
<li class="dropdown">
<a href="<?= base_url('categoria/' . $menu->txtUrlMenuSite); ?>"><?= strtolower($menu->txtMenu); ?></a>
<div class="dropdown-content">
<div class="col-xs-12">
<ul class="sub-nav">
<?php
foreach ($menu->subMenu as $key => $sub):
?>
<li><a href="<?= base_url('categoria/' . $sub->txtUrlMenuSite); ?>"><?= $sub->txtMenu; ?></a></li>
<?php
endforeach;
?>
</ul>
</div>
</div>
</li>
<?php
else:
?>
<li><a href="<?= base_url('categoria/' . $menu->txtUrlMenuSite); ?>"><?= strtolower($menu->txtMenu); ?></a></li>
<?php
endif;
?>
</li>
<?php
endforeach;
?>
You can put a piece of code to make the question clearer, friend?
– Woton Sampaio
puts a Count $Count = 0; foreach(sue foreachaqui) ģ echo "<div class='x$Count'></div>"; $Count++;}
– Marcos Brinner
Woton Sampaio, sorry friend I just edited the post, thank you very much!
– Gustavo Siqueira
Marcos Brinner, thank you very much, I’ll try now!
– Gustavo Siqueira