How can I increment a Smarty variable?

前端 未结 6 1137
梦毁少年i
梦毁少年i 2021-02-19 16:02

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...<

6条回答
  •  迷失自我
    2021-02-19 16:43

    {foreach from=$foo item=bar name=humbug}  
    {$smarty.foreach.humbug.index}
    {$smarty.foreach.humbug.iteration}
    {/foreach}
    

    or

    {foreach from=$foo item=bar name=berlin}  
    {$smarty.foreach.berlin.index}
    {$smarty.foreach.berlin.iteration}
    {/foreach}
    

提交回复
热议问题