Can someone tell me how to iterate over array keys without knowing their values ? For example:
array:3 [▼
"name" => "AccountId"
"activated" => "false"
"type" => "string"
]
I'd like to get a select list with:
<select name="select">
<option>name: AccountId</option>
<option>activated: false</option>
<option>type: string</option>
</select>
You can Iterating over Keys and Values as described in the doc, as example:
<select name="select">
{% for key, value in users %}
< option > {{ key }}: {{ value }}</option >
{% endfor %}
</select>
Something like this should do the trick:
<select>
{% for key, value in data %}
<option>{{ key }}: {{ value }}</option>
{% endfor %}
</select>
You can read more about for loop in Twig's documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With