How can I increment a Smarty variable?
- by alex
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...
<ul>
{foreach from=$gallery key=index item=image}
<li>
<img src="{$image}" alt="" id="panel-{$index++}" />
</li>
{/foreach}
</ul>
It doesn't work.
Is the best way to do this to pre-process the array before handing it to Smarty?
Is there a way I can do this using Smarty?