Home >Backend Development >PHP Tutorial >PHP array function sequence array_flip() swaps array key names and values_PHP tutorial
array_flip() Definition and usage
array_flip() function will swap the key name of the array with its corresponding value, that is, the key name becomes the value, and the value becomes the key name.
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.
Syntax
array_flip(array) Parameter Description
array Required. Specifies the input array.
Example