I wanted to echo an image every after 3 post via XML here is my code :
Going off of @Powerlord's answer,
"There is one catch: 0 % 3 is equal to 0. This could result in unexpected results if your counter starts at 0."
You can still start your counter at 0 (arrays, querys), but offset it
if (($counter + 1) % 3 == 0) {
echo 'image file';
}
You can also do it without modulus. Just reset your counter when it matches.
if($counter == 2) { // matches every 3 iterations
echo 'image-file';
$counter = 0;
}