Print array on Twig

Asked

Viewed 121 times

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’m having trouble printing it on Wig. 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 %}

1 answer

0


Tries:

{% for var in i %}

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

{% endfor %}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.