V
V
Vladislav Dmitruk2016-10-26 16:21:09
PHP
Vladislav Dmitruk, 2016-10-26 16:21:09

How to output an array in twig?

Hello.
I get data using some api, after receiving the data, I get a PHP array of the form
<?php $result[1]['name']; ?>
Where $resultis the array itself, [1] is the id of the array record, ['name'] is the value of the array record.
Next, I pass this array to twig (I checked it is not empty).
How can I loop it out?
Tried like this - {{ result.i.name }} where i is the id of the array entry.
I will be very grateful for the answer.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
@
@smple, 2016-10-29
_

{{result[1]['name']}}
but in your case it's better to use a for loop. twig.sensiolabs.org/doc/tags/for.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question