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">'; }