The array_flip() function exchanges all keys with their associated values in an array. It returns flipped array on success, else NULL on failure.
Syntax
array_flip(arr)
Parameters
arr − Specify the array of key/value pairs to be flipped.
Return
The array_flip() function returns flipped array on success, else NULL on failure.
Example
<?php $arr = array("p"=>"keyboard","q"=>"mouse","r"=>"monitor"); $res = array_flip($arr); print_r($res); ?>
Output
Array ( [keyboard] => p [mouse] => q [monitor] => r )