Concept of loops in PHP
The concept of loops is similar in c,c++, java , javascript etc. in any programming language but the only difference is the way of writing each loops in different languages.
Types of Loop
- While
- Do-While
- For Loop
- Foreach Loop
While loop:
$count=0;
While($count<5)
{
echo”
the count is “.$count;
$count++;
}
Do-while loop:
$count=0;
do
{
echo “
the count is”.$count;
$count++;
}
while($count>5)
For loop:
$price=5;
for($counter=10;$counter<=150; $counter+=10)
{
echo” counter value”;
}
Foreach loop:
foreach($array as $values)
{
echo “values”;
}
(Visited 296 times, 1 visits today)
Written by: