webCOMAND

#FOR

Repeat a block of cTemplate based on an initializer, condition and adjustment.

Prototype

#FOR(initializer; condition; adjustment) ... #ENDFOR

Parameters

  • initializer - An expression typically used to initialize a variable, such as $i = 1
  • condition - An expression that determines if the block should repeat again (TRUE) or terminate (FALSE), such as $i < 10
  • adjustment - An expression typically used to update a variable that will eventually cause the condition to fail, such as $i = $i + 1

Example

#FOR($i=1; $i<=3; $i=$i+1)
    Iteration $i<br/>
#ENDFOR

Result

Iteration 1
Iteration 2
Iteration 3

Related

#FOREACH, #WHILE