I can't figure out how to group my subcategories into a container after every fifth record.
for example I would like to output my subcats like this
<ul>
<li>
Main category
<div>
<div class="subcontainer">
sub1
sub2
sub3
sub4
sub5
</div>
<div class="subcontainer">
sub6
sub7
sub8
sub9
sub10
</div>
</div>
</li>
</ul>
I tried this:
<?php
$i=0;
foreach ($cat->sub as $child) {
if($i % 5 == 0){
echo '<div class="subcontainer"><div>'.$child->name.'</div></div>';
} $i++;
}
?>
But this will output only the 5th elements in the array.