I am not usually a Smarty guy, so I\'m a bit stuck.
I want to echo the index of an array, but I want to increment it each time I echo it.
This is what I have...<
You can do something like the following:
{foreach from=$gallery key=index item=image name=count}
-
{/foreach}
Starting from zero, index
is the current array index.
That's probably the best way to go about it, however, to simply use a counter outside of a foreach
loop you can use counter
, like so:
{counter start=0 skip=1 assign="count"}
To increment it simply call {counter}
at each iteration.
{counter}
{*Can then use the $count var*}
{if $count is div by 4}
{*do stuff*}
{/if}