The foreach statement, although it sounds like an extension of the for statement, is intended to be used while working with arrays and objects. The foreach statement gives an error with a regular variable.
Syntax for FOREACH statement
<?php
// one way
foreach (expression as $value)
{
// code goes here
}
// another way
foreach (expression as $key => $value)
{
// code goes here
}
?>
Example with a FOREACH statement
Comments
No comments have been made yet.
Please login to leave a comment. Login now