How can I increment a Smarty variable?

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2011-01-05T01:51:31Z Indexed on 2011/01/05 2:53 UTC
Read the original article Hit count: 224

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about smarty