Answers for "convert array to key value in php"

PHP
1

convert key to value php

<?php
$input = array("oranges", "apples", "pears");
$flipped = array_flip($input);
print_r($flipped);
?>
  
// output
Array (
    [oranges] => 0
    [apples] => 1
    [pears] => 2
)
Posted by: Guest on March-12-2021
4

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 "convert array to key value in php"

Browse Popular Code Answers by Language