exchanges all keys with their associated values in an array
by kalai[ Edit ] 2009-11-07 12:15:08
If we want to exchanges all keys with their associated values in an array, we can make use of array_flip function
$trans = array("a" => 1, "b" => 1, "c" => 2);
$trans = array_flip($trans);
print_r($trans);
?>
Result
Array
(
[1] => b
[2] => c
)
Here keys are changed to values and array values are changed to array key