2010-07-04 80 views
1

我需要循環進入智者和{部分}多維數組是給我很難Smarty的:多維數組

這是數組名爲$品牌:

Array (26) 
    A => Array (4) 
     0 => "Alienation" 
     1 => "Alligator" 
     2 => "Amoeba" 
     3 => "Animal" 
    B => Array (2) 
     0 => "Bell" 
     1 => "Bontrager" 
    C => Array (9) 
     0 => "Camicleta" 
     1 => "Cannondale" 
     2 => "Cateye" 
     3 => "Coach" 
     4 => "Colner" 
     5 => "Continental" 
     6 => "Crankbrothers" 
     7 => "Cratoni" 
     8 => "CST" 
    D => Array (7) 
     0 => "Da Bomb" 
     1 => "Deli" 
     2 => "Demolition" 
     3 => "Diadora" 
     4 => "Diamondback" 
     5 => "DNM" 
     6 => "DT Swiss" 
    E => Array (3) 
     0 => "Eastman" 
     1 => "Easton" 
     2 => "Eighties" 
    ... 

我要輸出

<h2>A</h2> 
     Alienation 
     Alligator 
     Amoeba 
     Animal 
<h2>B</h2> 
     Bell 
     Bontrager 
.... 

所以一個

我明白我應該在品牌陣列內重複了兩次,但不能讓它使用嵌套的foreach工作

回答

1

嘗試:

{foreach from=$myArr key=key item=item} 
    <h2>{$key}</h2> 
    {foreach from=$item item=i} 
     {$i} <br /> 
    {/foreach} 
{/foreach} 
+0

工作就像一個魅力,謝謝! – 2010-07-04 19:36:33