Print array on Twig

0

I have an array with the following structure:

array(20) {
  [0]=>
  array(13) {
    ["id_question"]=>
    string(10) "1312352154"
    ["date_created"]=>
    string(19) "2018-06-20 18:08:38"
    ["anuncio"]=>
    string(12) "XXXXX"
  }
  [1]=>
  array(13) {
    ["id_question"]=>
    string(10) "1231312313"
    ["date_created"]=>
    string(19) "2018-06-20 18:46:13"
    ["anuncio"]=>
    string(12) "ZZZZZ"
  }
  [2]=>
  array(13) {
    ["id_question"]=>
    string(10) "1231312313"
    ["date_created"]=>
    string(19) "2018-06-17 22:52:18"
    ["anuncio"]=>
    string(12) "YYYYY"
  }

I can not print it in twig. I tried this way.

{% extends 'formulario/layout.html' %}

{% block formulario %}

<h1> Home </h1>

{% for i in 0..20 %}

 <li>  {{ 0.id_question  }} </li>
 <li>  {{ 0.date_created }} </li>
 <li>  {{ 0.anuncio      }} </li>

{% endfor %}

{% endblock %}
    
asked by anonymous 21.06.2018 / 22:20

1 answer

0

Try:

{% for var in i %}

 <li>  {{ var.id_question  }} </li>
 <li>  {{ var.date_created }} </li>
 <li>  {{ var.anuncio      }} </li>

{% endfor %}
    
25.08.2018 / 03:52