Loops in PHP

 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

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...