Use the for each loops to cycle through arrays. At each pass, the value of the current array element is set to $value. In the next pass, the array pointer is moved one by one. The for each loop is only used to loop around each key/values pair in an array. Only arrays are supported.
Syntax:-
foreach ($array as $value) {
code to be executed;
}
Here are some of the Foreach Loops:-
“foreach(…){…}” is the foreach php loop block code
“$array_data” is the array variable to be looped through
“$array_value “ is the temporary variable that holds the current array item values.
“block of code…” is the piece of code that operates on the array values
The (do-while loop) is a version of the while loop in which the state is assessed at the end of each loop iteration. A (while loop) runs a block of code once and then evaluates the condition; if the condition is true, the expression is repeated as long as the condition is true.
Syntax:-
do {
code to be executed;
} while (condition is true);