I’m trying to get a new to fire the first time in my loop and then after 4 counts close the and then open a new in my loop i tried doing this with modulus but i don’t think I am doing it correctly.
Code I tried:
<?php for($i = 1; $i <= 12; $i++): ?>
<?php if(! (i % 4)): ?>
<div class="row">
<?php endif; ?>
<?php echo $i; ?>
<?php if(! (i % 5)): ?>
</div>
<?php endif; ?>
<?php endfor; ?>
So my results should be:
<div class="row">
1 2 3 4
</div>
<div class="row">
5 6 7 8
</div>
<div class="row">
9 10 11 12
</div>
etc…
The simplest solution would be to :
$i % 4 == 3, putting both an after and a before markersFor example, something like this portion of code :
Will give that kind of output :
Advantage of this solution : you do not have to deal with any specific case (beginning and end of the loop) inside the loop.