Definition and usage
The array_flip() function returns a reversed array. If the same value appears multiple times, the last key name will be used as its value, and all other key names will be lost.
If the data type of the value in the original array is not string or integer, the function will report an error.
Grammar
array_flip(array)
Parameters
Description
array required. Specifies the input array.
Example
"Dog",1=>"Cat",2=>"Horse");print_r(array_flip($a)); ?>
Output:
Array ( [Dog] => 0 [Cat] => 1 [Horse] => 2 )