2010-07-04 5 views
1

J'ai besoin de boucle dans un tableau multidimensionnel dans Smarty et {section} me donne malSmarty: tableau multidimensionnel

C'est le tableau appelé marques $:

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

Je veux à la sortie

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

Et un

Je comprends que je devrais itérer deux fois à l'intérieur du tableau de marques, mais ne peut pas faire fonctionner

Répondre

1

Essayez d'utiliser un foreach imbriqué:

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

travaillé comme un charme, Merci! –