Answers for "array foreach php example"

PHP
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
3

foreach in php

<?php
// Declare an array 
$arr = array("green", "blue", "pink", "white");  
  
// Loop through the array elements 
foreach ($arr as $element) { 
    echo "$element "; 
} 
?>
Posted by: Guest on July-09-2020
1

php ofreach

<?php

$a = array(1, 2, 3, 17);

foreach ($a as $index => $v) {
    echo "Current value of \$a: $v.\n";
}

?>
Posted by: Guest on April-23-2020
0

PHP foreach

<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");

 
foreach($age as $x => $val) {
  echo "$x = $val<br>";
}
?>
Posted by: Guest on September-16-2021

Browse Popular Code Answers by Language