Php Twig无法从2个合并阵列获取密钥
我有两个数组携带类似的数据,我只需要每个数组上的关键“推荐”部分的数据。 我知道如何从其中任何一个获取数据(openGames[#].推荐部分),但如何最好地从这两个部分获取数据Php Twig无法从2个合并阵列获取密钥,php,twig,Php,Twig,我有两个数组携带类似的数据,我只需要每个数组上的关键“推荐”部分的数据。 我知道如何从其中任何一个获取数据(openGames[#].推荐部分),但如何最好地从这两个部分获取数据 string(31) "openGames.testimonial_section" NULL string(32) "openGames[0].testimonial_section" array(1) { [0]=> array(2) { ["testimonial"]=> s
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 %}
我对twig很陌生,我很难通过文档过滤出如何做到这一点。希望你能帮忙。试试这个
{% for each_section in openGames %}
{% if each_section.testimonial_section != empty %}
{% for each_testimonial in each_section %}
{{ each_testimonial.testimonial }}
{% endfor %}
{% endif %}
{% endfor %}
如果更多信息有助于说明鉴定细节与鉴定部分的关系,那么可能转储细枝变量,然后说出您想要从中得到什么{{dump(var1)}}和{dump(var2)}typo,鉴定部分而不是testomonial_detailTypos是最失败的错误。