We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

for statement in volt

for($i=0; $i<5; $i+=0.1)
    // do something

//above in volt how to do

Unless there is something I am missing, I don't think you can since Volt uses the keyword 'for' for it's foreach loop. Only suggestion I would have for you is to implement this within a simple php block. You can execute vaild php blocks inside a Volt block, such as :

{% for post in posts %}
    <header class="post_header">
        <h3 class="post_title"><a href="{{ url('post/show/') }}{{ post.post_title}}">{{ post.post_title }}</a></h3>
        <span class="post_details"><small>{{ post.post_author }} - {{ post.created_at }}</small></span>
        <h5 class="post_desc">{{ post.post_desc }}</h5>

    for ($i=0; $i < 10; $i++) {
        echo $myVar;

    <article class="post_content">
        <?php echo Parsedown::instance()->parse(substr($post->post_content,0, 500)); ?>
{% endfor %}


Volt has for syntax: https://docs.phalcon.io/en/latest/reference/volt.html#for, but is usually intended for looping over iterable variables. Using Volt syntax, this should work:

{% for i in [0..50] %}
  {% set j = i/10 %}
{% endfor %}

The [0..50] creates a 50 element array