1

I have multidimensional array...

Array (2)
1 => Array (1)
  Body => Array (4)
    1 => "Color"
    3 => "Metal-Parts"
    4 => "Accessories"
    5 => "Materials"
2 => Array (1)
  Interieur => Array (1)
    2 => "Inner-Bags"

and i want to get result like this

> Body
    > Color
    > Metal-Parts
    > Accessories
    > Materials
> Interieur 
    >Inner-Bags

But i don't find the result and i am using this code..

[{assign var="labelarr" value=$myParam}]

[{foreach from=$labelarr key=key item=item}]

[{foreach from=$item[1] key=key1 item=item1}] 

     <h2>[{$key1}]</h2>   

[{/foreach}]

[{/foreach}]

But, i get the result in the like this..Only print

Body

So please help me.. Thanks....

3
  • 1
    that's because you are printing only key1 (body)... Commented Sep 26, 2012 at 7:54
  • So which variable put insted of 'from=$item[1]'. pleas tell me...Thanks... Commented Sep 26, 2012 at 13:03
  • You have accepted the only answer.. didn't that solve your issue? Commented Sep 26, 2012 at 13:04

1 Answer 1

1

How about

{foreach from=$labelarr key='label_key' item='label'}
   > {$label_key}
   {foreach from=$label item='label_child'}
     > {$label_child}
   {/foreach}
{/foreach}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.