2 Twig supports array notation
8 {{ ['foo', "bar"]|join(',') }}
9 {{ {0: 1, 'foo': 'bar'}|join(',') }}
10 {{ {0: 1, 'foo': 'bar'}|keys|join(',') }}
12 {{ {0: 1, foo: 'bar'}|join(',') }}
13 {{ {0: 1, foo: 'bar'}|keys|join(',') }}
16 {% set a = [1, 2, [1, 2], {'foo': {'foo': 'bar'}}] %}
18 {{ a[3]["foo"]|join(',') }}
20 {# works even if [] is used inside the array #}
21 {{ [foo[bar]]|join(',') }}
23 {# elements can be any expression #}
24 {{ ['foo'|upper, bar|upper, bar == foo]|join(',') }}
26 {# arrays can have a trailing , like in PHP #}
34 {# keys can be any expression #}
37 {% set ary = { (a): 'a', (b): 'b', 'c': 'c', (a ~ b): 'd' } %}
38 {{ ary|keys|join(',') }}
41 return array('bar' => 'bar', 'foo' => array('bar' => 'bar'))