当名称中有破折号时,如何呈现数组键的值?
我有这个片段:
$snippet = "
{{ one }}
{{ four['five-six'] }}
{{ ['two-three'] }}
";
$data = [
'one' => 1,
'two-three' => '2-3',
'four' => [
'five-six' => '5-6',
],
];
$twig = new \Twig_Environment(new \Twig_Loader_String());
echo $twig->render($snippet, $data);
输出是
1
5-6
Notice: Array to string conversion in path/twig/twig/lib/Twig/Environment.php(320) : eval()'d code on line 34
它渲染得four['five-six']
很好。但是在['two-three']
.