Answers for "PHP Loops, give each example program using PHP?"

PHP
10

foreach loop in php

$arr = ['Item 1', 'Item 2', 'Item 3'];

foreach ($arr as $item) {
  var_dump($item);
}
Posted by: Guest on June-01-2020
5

foreach loop in php

<?php
$arr = ['Item 1', 'Item 2', 'Item 3'];

foreach ($arr as $item) {
  var_dump($item);
}

$dict = array("key1"=>"35", "key2"=>"37", "key3"=>"43");

foreach($dict as $key => $val) {
  echo "$key = $val<br>";
}
?>
Posted by: Guest on June-28-2020
1

foreach loop in php

<?php
$food = array('burger','pizza','golgappa','momoes');
foreach($food as $value)
{
    echo $value,"<br>";
}
?>
Posted by: Guest on September-06-2021
0

php: foreach loop

Copyfor($i = 0; $i < 5; $i++){
     echo $i;
}

$luckyNums = [4, 8, 15, 16, 23, 42];
foreach($luckyNums as $luckyNum){
     echo $luckyNum."<br>";
}
Posted by: Guest on August-23-2021

Browse Popular Code Answers by Language