foreach construct only works with arrays.
This means you must either use an array like this:
array( '1', '2', '3' );
Or functions which return an array like
foreach is used to loop through each key/value pair in an array:
$key = array( '1', '2', '3' ); foreach( $key as $value ) print $value;
If you wrap the above code in opening and closing php tags and put it into a file, it will output 123.
That’s the most basic example of using foreach with an array.
Here’s several commonly used examples of using foreach with an array of key/value pairs as well as functions which return an array.
You need to pay to fully access this tutorial.
Enjoy unlimited access & coding support by registering.