The array_flip () function changes the key name of the array to its corresponding value, that is, the key name is changed to a value, and the value is changed to the key name array_flip () definition and usage.
The array_flip () function changes the key name of the array to the corresponding value, that is, the key name is changed to the value, and the value is changed to the key name.
The array_flip () function returns an inverted array. if the same value appears multiple times, the last key 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 a string or integer, the function reports an error.
Syntax
Array_flip (array) parameter description
Array is required. Specifies the input array.
Example
The code is as follows:
$ A = array (0 => "Dog", 1 => "Cat", 2 => "Horse"); print_r (array_flip ($ ));
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service