Answers for "for each as key"

PHP
9

php foreach

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

foreach($age as $x => $val) {
  echo "$x = $val<br>";
}
?>
Posted by: Guest on April-07-2020
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

Browse Popular Code Answers by Language