1

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.

1
  • 2
    {% for row in var['data'] %}{{ row.name }}{% endfor %} Commented May 11, 2017 at 15:03

1 Answer 1

2

@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 %}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.