Home > Backend Development > PHP Tutorial > arrays.sort PHP array_flip special function to delete duplicate array elements

arrays.sort PHP array_flip special function to delete duplicate array elements

WBOY
Release: 2016-07-29 08:42:50
Original
1590 people have browsed it

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 code The 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 result is:
 data2 data1 two data.

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template