Every 3rd Iteration of PHP Loop -
when 'every 3rd iteration' mean 'every 3rd iteration... starting number 4'
if every 3rd, target appropriate iterations so:
<?php if ($count % 3 == 0) : ?>
bear in mind i've set $count
1
beforehand
but iterations need start 4th, 7th, 10th etc.
does know how can acheive this? can simple if
statement 1 above?
unfortunately don't think for
loop possible wordpress loop i'm dealing with
your thoughts using modulus operator sound, need expand scope of logic surrounding it:
you want every third iteration after initial 4 have passed. begin logic after first 4:
if ($count > 4)
then, want each 3 after that. counter includes initial 4 iterations didn't want include, remove counter , check if current iteration multiple of 3:
if (($count - 4) % 3 === 0)
this should give you're looking for.
if ($count > 4) { if (($count - 4) % 3 === 0) { ... } }
you can put 1 line:
if ($count > 4 && ($count - 4) % 3 === 0) { ... }
Comments
Post a Comment