Universeorange.com/Docs/

R3m/framework Function reference for.each

{for.each (iterable_expression as $value)}
    statement
{/for.each}
{for.each (iterable_expression as $key => $value)}
    statement
{/for.each}

The foreach construct provides an easy way to iterate over arrays.
Foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable.
There are two syntaxes:

{for.each (iterable_expression as $value)}
    statement
{/for.each}
{for.each (iterable_expression as $key => $value)}
    statement
{/for.each}

The first form traverses the iterable given by iterable_expression.
On each iteration, the value of the current element is assigned to $value.

The second form will additionally assign the current element's key to the $key variable on each iteration.

Note that for.each does not modify the internal array pointer, which is used by functions such as current() and key().

It is possible to customize object iteration.

More information:

https://www.php.net/manual/en/control-structures.foreach.php

Last modified: 2021-06-07

© 2021 universeorange.com