tags:

views:

41

answers:

1

Hello,

I working on smarty template.

I need to have numbers to my list array

So I tried

{foreach} {$num} {/foreach}

Which prints 0 1 2 3 4 5 ........

I want my numbers to starts from 1 & not 0

How can I achieve this?

OR

Is there any other way to do it ?

Thanks

+1  A: 

{foreach} {$num|assign:$num+1} {$num} {/foreach}

or

{foreach}{assign var=newnum value=$num+1} {$newnum} {/foreach}

Christian Smorra
It is still starts from 0
MANnDAaR
`++$num` perhaps, since he wants to start from 1?
roddik
try this new example
Christian Smorra
++$num shows bug
MANnDAaR
yea i think ++$num is not implemented in smarty but this should do the trick
Christian Smorra
Smart!!! your {assign var=newnum value=$num+1} worked perfect.. Thanks
MANnDAaR
youre welcome :)
Christian Smorra
only {$num+1} also did the trick..
MANnDAaR
occams razor :P
Christian Smorra