Reputation: 3730
i have a array like this and want to get the content.
Array
(
[0] => Array
(
[0] => 1
[id] => 1
[1] => Testnews
[title] => Testnews
[2] => Dies ist eine kleine <strong>Testnews!</strong>
[text] => Dies ist eine kleine <strong>Testnews!</strong>
[3] => 1
[type] => 1
[4] => 1
[timestamp] => 1
[5] => 0
[status] => 0
)
)
I tried the following:
{% for latest_news in news %}
{% for id, title in latest_news %}
id : {{ id }}
title : {{ title }}
{% endfor %}
{% endfor %}
That works, but i don't think this is the right way to do this.
How should it look like?
Upvotes: 0
Views: 689
Reputation: 3730
I just found the right and easiest solution:
{% for latest_news in news %}
id : {{ latest_news.id }}
title : {{ latest_news.title }}
{% endfor %}
Upvotes: 2
Reputation: 905
I'd say that's right. You could also do:
{% for latest_news in news %}
{% for news_item in latest_news %}
id: {{ news_item.id }}
title: {{ news_item.title }}
{% endfor %}
{% endfor %}
Upvotes: 0