Answers for "print array key and value 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
6

php all keys in array

<?php
$array = array(
    'fruit1' => 'apple',
    'fruit2' => 'orange',
    'fruit3' => 'grape',
    'fruit4' => 'apple',
    'fruit5' => 'apple');

$keys = array_keys($array);		// return array
$values = array_values($array);	// return array
?>
Posted by: Guest on April-29-2020
3

array key value php

<?php
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
foreach($age as $x=>$x_value)
  {
  echo "Key=" . $x . ", Value=" . $x_value;
  echo "<br>";
  }
?>
Posted by: Guest on March-12-2020

Code answers related to "print array key and value in php"

Browse Popular Code Answers by Language