The `
foreach
` loop is a type of loop statement in PHP that allows you to iterate over the elements of an array or an object.
The basic syntax of a `
foreach
` loop in PHP is as follows:
foreach ($array as $value) {
// code to execute for each element in the array
}​
In this syntax, `
$array
` is the array that you want to iterate over, and `
$value
` is a variable that will be assigned the value of each element in the array as you loop through it.
For each iteration of the loop, the code inside the loop is executed, with `
$value
` representing the current element of the array.
Here's an example of a PHP program that uses a `
foreach
` loop to iterate over an array of names and print each name :