Reputation: 393
I have an array of the following form with many items. How can I get the values of the "data" key in Twig?
array(4) {
["schema"]=>
string(20) "decision_public.json"
["data"]=>
array(10) {
[0]=>
array(8) {
["id"]=>
string(23) "looks_bad_account_abuse"
["name"]=>
string(9) "Looks Bad"
}
I tried for
inside a for
, but I cant get the data.
Upvotes: 1
Views: 691
Reputation: 393
@DarkBee you gave me an idea here is the solution:
{% for key, decision in decisions %}
{% if key=='data' %}
{% for item in decisions['data'] %}
<option>{{item.id}}</option>
{% endfor %}
{% endif %}
{% endfor %}
Upvotes: 2