Twig Template For loop Results
- by user981480
I am trying to print out a the contents of an array but am not getting the expected results. any help is much appreciated:
PHP code:
$list[1]['first_name'] = 'Joe';
$list[1]['last_name'] = 'Smith';
$list[2]['first_name'] = 'John';
$list[2]['last_name'] = 'brand';
$data = array(
'customer' => $list
);
echo $template->render($data);
Template Markup:
<html>
<head><title>My first Twig template!</title></head>
<body>
{% for person in customer %}
{{ person.first_name }}
{% endfor %}
</body>
RESULTS:
Array
(
[first_name] = Joe
[last_name] = Smith
)
first_name
Joe
Array
(
[first_name] = John
[last_name] = brand
)
first_name
John