What is For each loop in PHP?
Advertisements
Question
What is For each loop in PHP?
Short/Brief Note
Advertisements
Solution
- For each loop is exclusively available in PHP.
- It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array.
- For each, loop iteration the value of the current array element is assigned to $value variable and the array pointer is shifted by one, until it reaches the end of the array element.
shaalaa.com
Looping Structure
Is there an error in this question or solution?
APPEARS IN
RELATED QUESTIONS
What will be displayed in a browser when the following PHP code is executed:
<?php
for (Scounter = 20; $counter< 10;
$counter++)
{
echo “Welcome to Tamilnadu “;
}
echo “Counter is: Scounter”;
?>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 Looping Structure in PHP.
Explain the use of for each loop in PHP.
Write the features Looping Structure.
Differentiate For each and While loop.
Differentiate While and Do while loops.
Explain the process Do while loop.
Explain concepts of for loop with example.
Explain working of loops in array.
