I am trying to forward (render) my array from php to the twig template and than print everything out in the template. My problem is to access the array in the twig template.
Php array and render function:
while ( $row = mysqli_fetch_array ( $queryResult ) )
{
$tplArray = array (
array (
'id' => $row ['id']
),
array (
'name' => $row ['name']
)
);
$tplArray = array (
'id' => $row ['id'],
'name' => $row ['name']
);
}
return $this->render ( 'work/work.html.twig', array (
'data' => $tplArray
) );
Trying to access the array in the twig template:
{% for entry in data %}
{{ entry.id }}
{{ entry.name }}
{% endfor %}
This obviously do not work. How can I get the data (id, name) from my $tplArray and print it out in the template?