I use Twig and I have an array with key like this :
array[1] = "alpha"
array[2] = "bravo"
array[3] = "charlie"
array[8] = "delta"
array[9] = "echo"
And I would like to get the key (1,2,3,8,9)
and the content (alpha, bravo, charlie, delta, echo)
in a loop to get all value of this array.
How I can do this ?
Thank you
I guess you want to do the "Iterating over Keys and Values"
As the doc here says, just add "|keys" in the variable you want and it will magically happen.
It never hurts to search before asking :)
There's this example in the SensioLab page on the
for
tag:http://twig.sensiolabs.org/doc/tags/for.html#iterating-over-keys
I found the answer :