Answers for "loop key value array in php"

PHP
5

php foreach echo key value

foreach($page as $key => $value) {
  echo "$key is at $value";
}
Posted by: Guest on September-04-2020
2

php for array key value

<?php
$array = array(1=>"apple",2=>"Orange",3=>"Banana");

foreach($array as $key => $value){
	echo "The value for " . $key . " is " . $value;
}
/*The value for 1 is apple
The value for 2 is Orange
The value for 3 is Banana

$array = [1 => "apple", 2 => "Orange", 3 => "Banana"    
    Is also valid
];*/  
?>
Posted by: Guest on February-01-2021
0

loop over keys and values php

foreach ($arr as $key => $value) {
 echo $key;
}
Posted by: Guest on May-06-2021

Browse Popular Code Answers by Language