Search code examples
phpfat-free-framework

Fat Free PHP: How to repeat over an int?


Using Fat Free PHP I am trying to repeat over an int value:

<repeat group="{{ @totalIterations }}" value="{{ @i }}">
     {{ @i }}<br/>
</repeat>

But it is not working, my desired result would be something like:

for ($i = 0; $i < $totalIterations; $i++) {
     {{ @i }}<br/>
}

Solution

  • repeat group is equivialent of foreach in php. Loop would be the same as a for loop:

    <loop from="{{ @i=0 }}" to="{{ @i < @totalIterations }}" step="{{ @i++ }}">
        {{ @i }}<br/>
    </loop>
    

    fat free documentation