Array_flip () Definition and usage
The Array_flip () function swaps 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.
The Array_flip () function returns an inverted array, and if the same value occurs more than once, the last key name is the value, and all other key names are lost.
If the data type of the value in the original array is not a string or an integer, the function will error.
Grammar
Array_flip (Array) parameter description
Array required. Specifies the input array.
Example
Copy CodeThe code is as follows:
$a =array (0=> "Dog",1=> "Cat",2=> "Horse");p Rint_r (Array_flip ($a));
?>
Output:
Array ([Dog] = 0 [Cat] + 1 [Horse] + 2)
http://www.bkjia.com/PHPjc/324616.html www.bkjia.com true http://www.bkjia.com/PHPjc/324616.html techarticle Array_flip () defines and uses the Array_flip () function to 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. The Array_flip () function returns a reversal after ...