A PHP function that exchanges all keys with their associated values in an array.
PHP
array_flip()
function exchanges all keys with their associated values in an array and returns an array in flip order. manual
Example
$input = array("oranges", "apples", "pears");
$flipped = array_flip($input);
print_r($flipped);
Result
Array
(
[oranges] => 0
[apples] => 1
[pears] => 2
)