Loop Block — Dwoo PHP Template Engine

Documentation for the Dwoo loop block tag. Iterate over arrays with automatic scope change, combining foreach and with functionality.

Loops over an array of arrays and allows for really simple / small constructs by moving the scope down to each element automatically. It is basically a combination of foreach and with internally.

loop(array $from [, $name = "default ] )

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




Example:

{loop $users}
{$id}-{$name}
{/loop}

Data:

'users' => array( 1 => 'Bob', 2 => 'John' )

Output:

1-Bob
2-John 

[edit] Accessing the array key

To access the array key you have to use the {$_key} var within the loop, its name is not user-definable to keep this plugin as simple as possible.

[edit] Extra reads