for

1.0 1.1 1.2 1.3

Similar to the php for statement

<?php
for(string $name, mixed $from, [ int $to = null, [ int $step = 1, [ int $skip = 0 ]]])

Note that this plugin supports iterator variables through the name parameter and also supports the else plugin

Examples

Example #1

index.tpl
{for i 0 5} {$i} {/for}
 
{for i 0 5 2} {$i} {/for}
 
{$arr=array("Bob","John","Jim")}
{for i $arr}
  {$i} -> {$arr.$i} {* or $arr[$i] *}
{/for}

The above example will output:

0  1  2  3  4  5 
0  2  4 
0 -> Bob
1 -> John
2 -> Jim