Description
array array_flip (array trans)
array_flip() returns a reversed array, for example, the key names in trans become values, and the values in trans become key names.
Note that the value in trans needs to be a legal key name, for example, it needs to be integer or string. A warning will be emitted if the value is of the wrong type, and the key/value pair in question will not be reversed.
If the same value appears multiple times, the last key name will be used as its value, and all others will be lost.
array_flip() returns FALSE if it fails.
Example:
Copy codeThe code is as follows:
$hills=array("first"=>"data1","second"=>"data2","third"=>"data1 ″);
$hills=array_flip($hills); //Restore key name
$hills1=array_flip(array_flip($hills));//Delete duplicates
display $hills1
The above introduces arrays.sort PHP array_flip special function for deleting duplicate array elements, including arrays.sort. I hope it will be helpful to friends who are interested in PHP tutorials.