In PHP, 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.
In PHP, 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.
* https://www.php.net/manual/en/control-structures.foreach.php
* PHP foreach
Loop: https://www.w3schools.com/php/php_looping_foreach.asp
PHP | |
---|---|
PHP | |
---|---|
The above always returns the value of the element, not the index, no matter if the array is ordered or is key-value. To get the key also: