Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Simple WHILE

Hi all,

i'm not able to realize a simple for N times loop in VOLT. Has far as i can see there is no WHILE statement and FOR works only with arrays.

Currently i'm using array_fill from the controller to pass an array of N NULL elements to the template to iterate over it but i downvote for this approach. I've also tried something like

{% FOR i in 5 %}

but PHP, obviously, reported: PHP Warning: Invalid argument supplied for foreach()


See define of foreach in PHP :)


I suppose to know what foreach means. VOLT FOR statement is equal to PHP FOREACH. But how to have a simple loop in VOLT? Ex: Print 5 times the letter 'a' in VOLT.


you mean like this ? {% for a in 0..10 %} {{ a }} {% endfor %}


thanks linbob! This is exactly what i meant! Thanks very much!

In the documentation the only reference for this is in Operators=>Range. A clear example of the usage may help readers to find out this feature. Regards