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
PHP supports which types of looping techniques ______.
Consider the following code
<? php
$count=12;
do{
printf(“%d squared=%d<br/>”,
$count, pow($count,2));
} while($count<4);
?>
What will be the output of the code.
Define for loop in PHP.
List out Looping Structure in PHP.
Write Syntax of Do while loop in PHP.
Explain the use of for each loop in PHP.
Write the purpose of Looping Structure in PHP.
Differentiate While and Do while loops.
Explain the process Do while loop.
Explain working of loops in array.
