PHP array_flip() special function to delete duplicate array elements_PHP tutorial

WBOY
Release: 2016-07-21 15:37:49
Original
1178 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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321898.htmlTechArticleDescription array array_flip (array trans) array_flip() Returns a reversed array, such as the key name in trans becomes the value, and the value in trans becomes the key name. Note the value in trans...
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