smarty using index to get the value in array

smarty using index to get the value in array

am 12.11.2007 23:06:24 von dkfjldfsa

I want to achieve the following process in the smarty
for $item['menu' . $i] one i should be able to get the value using
loop.index, but
without any luck.

any help is appreciated.




value=""/>
value=""/>



====SMARTY====
{section name=loop start=1 loop=30}

{$smarty.section.loop.index}
{assign var="i" value=$smarty.section.loop.index}
value="{$item}{'menu$i}"/>

{/section}

Re: smarty using index to get the value in array

am 13.11.2007 10:36:35 von badar.waqas

On Nov 13, 3:06 am, "sksksk" wrote:
> I want to achieve the following process in the smarty
> for $item['menu' . $i] one i should be able to get the value using
> loop.index, but
> without any luck.
>
> any help is appreciated.
>
>
>
>
> > value=""/>
> > value=""/>
>
>
>
> ====SMARTY====
> {section name=loop start=1 loop=30}
>
> {$smarty.section.loop.index}
> {assign var="i" value=$smarty.section.loop.index}
> > value="{$item}{'menu$i}"/>
>
> {/section}

I think this will work

{section name=loop start=1 loop=30}

{$smarty.section.loop.index}
{assign var="i" value=$smarty.section.loop.index}
{assign var="arrayIndex" value="menu".
$smarty.section.loop.index."_price"}
value="{$item.$arrayIndex}"/>

{/section}

Store array index in variable and then access it.