Advertisements
Advertisements
प्रश्न
Discuss in detail about Foreach loop.
थोडक्यात उत्तर
Advertisements
उत्तर
- 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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
APPEARS IN
संबंधित प्रश्न
The loop exclusively used for arrays is _____.
PHP supports which types of looping techniques ______.
What will be the output of the following PHP code?
<?php
for ($x = -1; $x < 10;--$x)
{
print $x;
}
?>Define 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 short notes on Do while Loop.
Differentiate While and Do while loops.
Explain concepts of for loop with example.
