Blogger Information
Blog 20
fans 0
comment 0
visits 19641
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP去重的简单写法
大鱼
Original
983 people have browsed it

PHP去重的简单写法
用array_flip实现去重效果

<?php
$arr =array("a"=>"a1","b"=>'b1',"c"=>"a2","d"=>"a1");$arr1 = array_flip($arr);print_r($arr1);//先反转一次,去掉重复值,输出Array ( [a1] => d[b1] => b [a2] => c )  后者优先替代前面的$arr2 = array_flip($arr1);print_r($arr2);//再反转回来,得到去重后的数组,输出Array([d] => a1 [b] => b1 [c] => a2)?>

此去重效果比array_unique要快

转自:http://newmiracle.cn/?paged=7&cat=3

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post