Answers for "PHP foreach"

CSS
67

php loop through array

$clothes = array("hat","shoe","shirt");
foreach ($clothes as $item) {
	echo $item;
}
Posted by: Guest on June-25-2019
9

php foreach

$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
8

foreach loop array php

foreach (array as $value){ 
  //code to be executed; 
  print("value : $value");
} 

foreach (array as  $key => $value){ 
  //code to be executed; 
  print("key[$key] => $value");
}
Posted by: Guest on April-12-2020
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
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