Php 我可以将关联数组发送到包含的细枝模板中吗?
我正在尝试将关联数组发送到细枝模板,其中包括:Php 我可以将关联数组发送到包含的细枝模板中吗?,php,include,twig,associative-array,Php,Include,Twig,Associative Array,我正在尝试将关联数组发送到细枝模板,其中包括: {% include 'my-template.twig' with { items: [ [ 'property' => 'value', 'other' => 'value' ], [ 'property' => 'value', 'other' => 'value'
{% include 'my-template.twig' with {
items: [
[
'property' => 'value',
'other' => 'value'
],
[
'property' => 'value',
'other' => 'value'
]
]
} %}
我得到这个错误:
PHP致命错误:未捕获异常“Twig\u error\u Syntax”,消息为“数组元素后面必须跟逗号”。值“=”的意外标记“运算符”(“标点符号”应为值“,”)
它似乎不喜欢
=>
。这是我的语法吗?有没有办法做到这一点?将关联数组的开始和结束[]
更改为{}
,将键=>
更改为:
[
{
'property':'value',
'other':'value'
},
{
'property':'value',
'other':'value'
}
]
{% include 'my-template.twig' with {
items: {
{
'property': 'value',
'other': 'value'
},
{
'property': 'value',
'other': 'value'
}
}
} %}