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
The loop exclusively used for arrays is _____.
What will be the output of the following PHP code?
<?php
for ($x = -1; $x < 10;--$x)
{
print $x;
}
?>Define for loop in PHP.
List out Looping Structure in PHP.
Explain the use of for each loop in PHP.
Write short notes on Do while Loop.
Differentiate While and Do while loops.
Explain Looping Structure in PHP.
Explain concepts of for loop with example.
Explain working of loops in array.
