Thursday, August 11, 2022

foreach Loops in php | PHP Tutorial #15

 Youtube:

foreach Loops in php | PHP Tutorial #15


Blogpost:

https://www.codewithharry.com/videos/php-tutorials-in-hindi-15/



Code as described/written in the video

<?php
echo "Welcome to the world of foreach loops <br>";
$arr = array("Bananas", "Apples", "Harpic", "Bread", "Butter");

// for ($i=0; $i < count($arr); $i++) { 
//     echo $arr[$i];
//     echo "<br>";
// }

// Better way to do this - foreach loops
foreach ($arr as  $value) {
    echo "$value <br>";
}

?>

No comments:

Post a Comment