2015-11-13 47 views
2

我有一個數組,它看起來像這樣出現---樹枝定義瞭如何在視圖

Array 
(
    [0] => Array 
     (
      [0] => Category ID 
      [1] => Category 
      [2] => Country 
      [3] => Sale price 
      [4] => Price 
      [5] => Currency 
      [6] => VAT 
      [7] => Product name 
      [8] => Description 
      [9] => product-image-1-url 
      [10] => SKU 
      [11] => Stock 
      [12] => Variation name 
      [13] => PropertyName 
      [14] => PropertyValue 
     ) 

) 

所以,當我試圖證明它在我的樹枝文件顯示,我應該想查看吧!

{% for label in labelsUnq%} 
    <thead> 
    <td> 
     {%if label is defined %} {{label}}{% endif %}          
    </td> 
    </thead> 

所以我應該寫在這裏{{label}}表現出與陣列中的所有值,任何人都知道如何解決這個問題!

回答

1

你需要兩個for循環:

{% for array in labelsUnq%} 
    {% for value in array %} 
     ... 
      {{label}}          
     ... 
    {% enfor %} 
{% endfor %} 
+0

非常感謝您的回答:) –

1

我相信這是你要找的代碼(我也感動了<thead>標籤圈外):

<thead> 
{% for key,value in labelsUnq %} 
    <td>{{ value }}</td> 
{% endfor %} 
</thead> 

更多信息可以在Twig documentation找到。

+0

非常感謝或你的答案:) –