twig index loop code example
Example 1: twig loop variables
{% for user in users %}
{{ loop.index }} - {{ user.username }}
{% endfor %}
Example 2: twig for loop key
{% for key, user in users %}
<li>{{ key }}: {{ user.username|e }}</li>
{% endfor %}
Example 3: index first twig
{{ loop.index }}
OR
{{ loop.index0 }}