There is an alternative (I think a newer) technique for this. An example from Smarty docs demonstrates this beautifully:
{foreach $items as $i} {if $i@index eq 3} {* put empty table row *} <tr><td>nbsp;</td></tr> {/if} <tr><td>{$i.label}</td></tr> {/foreach}
Note that the index starts at zero, so index 3 is the 4th iteration.
source share