重点"路径"与钥匙&QUOT阵列;"而转储说,它不存在 [英] Key "path" for array with keys "" does not exist while dump says it does
本文介绍了重点"路径"与钥匙&QUOT阵列;"而转储说,它不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前的CMS工作使用的Symfony2作为底层框架和小枝作为模板引擎。
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 %}
抛出exeption。
throws an exeption.
的键道与按键,数组不存在的
图像阵列的树枝转储返回这样的:
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 %}
这篇关于重点"路径"与钥匙&QUOT阵列;"而转储说,它不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文