We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Convert foreach in php to for in Volt template

Hi all, I have a code, please give me convert to volt template:

I want to turn $i+1 increase per unit when the foreach loop in Volt template

<?php $i=1; foreach($arr as $value){
echo $i;
$i++;
}?>


145.0k
Accepted
answer
edited Mar '16
{% set i = 1 %}
{% for value in arr %}
{{ i }}
{% set i += 1 %}
{% endfor %}

ok thanks so much