twig for loop key code example
Example 1: how to for loop twig
{% for letter in 'a'..'z' %}
* {{ letter }}
{% endfor %}
Example 2: twig for loop key
{% for key, user in users %}
<li>{{ key }}: {{ user.username|e }}</li>
{% endfor %}
{% for letter in 'a'..'z' %}
* {{ letter }}
{% endfor %}
{% for key, user in users %}
<li>{{ key }}: {{ user.username|e }}</li>
{% endfor %}