twig foreach print index code example
Example 1: twig for
{% for key, user in users %}
- {{ key }}: {{ user.username|e }}
{% endfor %}
Example 2: twig loop
{% for user in users %}
{{ loop.index }} - {{ user.username }}
{% endfor %}