Reputation: 28106
So i need it to run on the first loop and then every 3rd loop
if ($k % 3 || $k==1 ) { echo '<div class="modcontainer">'; }
Seems simple to me, but i don't have the understanding of modulus
Upvotes: 5
Views: 10180
Reputation: 24222
Modulus returns the remainder, not a boolean value.
This code will resolve to true
for 1, 3, 6, 9, ...
if (($k % 3 == 0) || $k==1 ) { echo '<div class="modcontainer">'; }
This code will resolve to true
for 1, 4, 7, 10, ...
if ($k % 3 == 1) { echo '<div class="modcontainer">'; }
Upvotes: 12