Loops in PHP
Loops are used to execute a block of code repeatedly. PHP supports different types of loops such as for loop, while loop, and foreach loop.
Example:
php
for($i=1; $i<=5; $i++){
echo $i . "<br>";
}
$numbers = array(1,2,3,4,5);
foreach($numbers as $number){
echo $number . "<br>";
}
No comments:
Post a Comment