Advertisements
Advertisements
Question
Discuss in detail about Foreach loop.
Answer in Brief
Advertisements
Solution
- The foreach statement is used to loop through arrays.
- For each pass the value of the current array element is assigned to $value and the array pointer is moved by one and in the next pass next element will be processed.

Foreach loop Structure and Flow - Syntax:
foreach ($array as $value) { code to be executed; } -
Example:
<?php $Student_name = a rrayÇ’MagiIan’ “Iniyan’ “NiIani’ “Sibi’ “Shini”); foreach ($Student_name as $value) { echo “$value <br>”; } ?>
shaalaa.com
Looping Structure
Is there an error in this question or solution?
APPEARS IN
RELATED QUESTIONS
Which loop evaluates condition expression as Boolean, if it is true, it executes statements and when it is false it will terminate?
Define for loop in PHP.
What is For each loop in PHP?
List out Looping Structure in PHP.
Write Syntax of For loop in PHP.
Write Syntax of For each loop in PHP.
Compare for loop and for each loop.
Explain the use of for each loop in PHP.
Write the purpose of Looping Structure in PHP.
Differentiate While and Do while loops.
