Skip to main content

Loops

foreach — Iterate array

Full reference →

The FOREACH loop iterates over an array, assigning the current key and value to variables for each iteration.

Syntax

XML
<foreach var="arrayName" var_value="val" var_key="key">
<output>Key: $key, Value: $val</output>
</foreach>

for — Counting loop

Full reference →

The FOR loop iterates through a range of integers or steps.

Syntax

XML
<for var="i" from="1" to="10">
<output>Count: $i</output>
</for>

while — Conditional loop

Full reference →

The WHILE loop repeats as long as a condition is true.

Syntax

XML
<while value1="$count" func="&gt;" value2="0">
<!-- loop body -->
</while>

repeat / until — Post-test loop

Full reference → | Full reference →

The REPEAT/UNTIL loop always executes at least once and repeats until a condition becomes true.

Syntax

XML
<repeat>
<!-- body -->
<until value1="$x" func="=" value2="0" />
</repeat>