do

Summary

Creates a do...while loop.

Usage

{do}
    [ {delimiter}...{/delimiter} ]
    [ {break}    ]
    [ {continue} ]
    [ {skip}     ]
{/do while <condition> [ sequence <array> as $seqVar ]}

Description

This mechanism is very similar to the "while" construct, except that the expression is checked at the end of each iteration instead of in the beginning. The main difference is that this construct will always execute the first iteration (regardless of how the test expression evaluates). It supports breaking, continual and skipping.

Examples

Example 1

{do}
 
    Keep printing this line ({$counter}) <br />
    {set $counter=inc( $counter )}
 
{/do while ne( $counter, 8 )}

If the initial value of $counter is 0, the following output will be produced:

Keep printing this line (0)
Keep printing this line (1)
Keep printing this line (2)
Keep printing this line (3)
Keep printing this line (4)
Keep printing this line (5)
Keep printing this line (6)
Keep printing this line (7)
Keep printing this line (8)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2013 eZ Systems AS (except where otherwise noted). All rights reserved.