2017-01-31 43 views
0

我有2個陣列攜帶類似數據的,我只需要從他們每個人的關鍵「testimonial_section」數據。 我知道如何從他們中的任何一個獲取數據(openGames [#]。testimonial_section),但是我怎樣才能最好地從兩者中獲取數據?嫩枝麻煩鍵合併陣列

string(31) "openGames.testimonial_section" 
NULL 

string(32) "openGames[0].testimonial_section" 
array(1) { 
    [0]=> 
    array(2) { 
    ["testimonial"]=> 
    string(32) " 
"the kidnapping" Test 1 


" 
    ["author"]=> 
    string(13) "test author 1" 
    } 
} 

string(32) "openGames[1].testimonial_section" 
array(2) { 
    [0]=> 
    array(2) { 
    ["testimonial"]=> 
    string(34) " 
norcross kidnapping test 1 


" 
    ["author"]=> 
    string(28) "norcross kidnapping author 1" 
    } 
    [1]=> 
    array(2) { 
    ["testimonial"]=> 
    string(34) " 
norcross kidnapping test 2 


" 
    ["author"]=> 
    string(28) "norcross kidnapping author 2" 
    } 
} 

最後,我需要有數據的條件基於一個或者陣列,我試圖運行像...

{% if testimonial_section != empty %} 
    {% for each_section in testimonial_section %} 
    {{ each_section.testimonial }} 
    {% endfor %} 
{% endif %} 

我很新的枝杈和我無法過濾如何通過文檔完成此操作。希望你能幫助。

+0

如果更多的信息,將有助於只是具體 –

+0

如何testimonial_detail涉及到testimonial_section,也許轉儲樹枝變量,然後說,你從他們想要什麼{{轉儲(VAR1)} }和{{dump(var2)}} – hounded

+1

錯字,testimonial_section不是testomonial_detail –

回答

0

試試這個

{% for each_section in openGames %} 
     {% if each_section.testimonial_section != empty %} 
     {% for each_testimonial in each_section %} 
      {{ each_testimonial.testimonial }} 
     {% endfor %} 
     {% endif %} 
    {% endfor %}