July 2018
Beginner
552 pages
13h 18m
English
The foreach loop is probably the most used loops. It will run through a defined collection and execute the script with a dynamic variable for each object in the defined collection. It is very handy when you need to do something with all of the values in a collection. The simple syntax looks as follows:
# simple syntax of a foreach-loop# foreach ($<item> in $<collection>)# {# <statement list># }
You start off with the foreach keyword, followed by looping parentheses. Here, you start with $<item>, which is a not defined variable, followed by the in keyword and the collection that you want to loop through. After each execution of the statement, the dynamic variable will be filled up with the next object in the collection. Let's ...
Read now
Unlock full access