关键“路径"对于带有键“"的数组转储说它不存在时不存在 [英] Key "path" for array with keys "" does not exist while dump says it does
本文介绍了关键“路径"对于带有键“"的数组转储说它不存在时不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在开发一个使用 symfony2 作为底层框架和 twig 作为模板引擎的 cms.
I'm currently working on a cms using symfony2 as the underlying framework and twig as the template engine.
我的问题如下:
此时
{% for image in images %}
{{ dump(image.path is defined) }}
{% endfor %}
为数组中的每个元素返回 true,...
returns true for each element in the array,...
...但是这个
{% for image in images %}
{{ image.path}}
{% endfor %}
抛出异常.
带有键"的数组的键路径"不存在
图像数组的树枝转储返回:
A twig-dump of the images-array returns this:
array(2) {
[0]=> object(stdClass)#2759 (9) {
["id"]=> string(5) "17795"
["typ"]=> string(3) "jpg"
["path"]=> string(10) "Tulips.jpg"
}
[1]=> object(stdClass)#2874 (9) {
["id"]=> string(5) "17796"
["typ"]=> string(3) "jpg"
["path"]=> string(14) "Hydrangeas.jpg"
}
}
这对我来说似乎很矛盾,我真的不明白这一点.有人有想法吗?非常感谢,截止日期即将到来...:/
This seems to be paradox to me and i really don't understand this. Has someone an Idea? I would be very thankful, deadlines are coming... :/
推荐答案
我想你创建了多维数组.也可以在树枝模板中尝试 foreach 循环以获取图像
I think u created multidimensional array. Try foreach loop in twig template for image also
{% for image in images %}
{% for i in image %}
{{ i.datei }}
{% endfor %}
{% endfor %}
这篇关于关键“路径"对于带有键“"的数组转储说它不存在时不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文