Flip all keys with their associated values in an array in PHP

Description

The following code shows how to flip all keys with their associated values in an array.

Example


<?php/*  ww  w . ja va2  s .co m*/
   $a1=array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow");
   $result=array_flip($a1);
   print_r($result);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone