Onetastic Macro Documentation >
>
foreach
foreach Statement
Description
Iterates over a given array, stores each element in the array in the given value variable and optionally its index into a key variable, and executes a set of for each iteration. You can break out of a foreach loop using a break statement or skip to the next iteration using a continue statement.
Syntax
Copied!
foreach ($keyVar => $valueVar in array-expression)
Statements...
Examples
Copied!
$person = Array("name" => "Fred", "age" => 32, "gender" => "male")
foreach ($key => $value in $person)
InsertObject($Outline, "Paragraph", -1).text = $key & ": " & $value
$sum = 0
foreach ($number in [3, 5, 7, 9])
$sum += $number
See Also
|