# Foreach
TIP
- The Foreach loop is used for going through an array keys and values, or only the values.
# Usage
- You can use foreach in either one line of code, or multiple lines, the format for 1 line of code is:
foreach (<array> as <key variable> => <value variable>) { #Code }
- And for multiple lines:
foreach (<array> as <key variable> => <value variable>) { # Code }
- Or if you only wanted to go through the values of the array without the keys, then the format would be:
(<array> as <value variable>)
# Parameters:
<array>
The array to go through<key variable>
The variable name to define the current key of the array<value variable>
The variable name to define the current value of the array
# Example:
1: $array$ = array("Acsrel", "Steve", "Alex")
2: foreach ($array$ as $arrayKey$ => $value$) {
3: sendMessage($player$, $arrayKey$ + ' => ' + $value$)
4: }