string(4) "古牧" [2]=> string(0) "" } }现在要给这个数组新增"/> string(4) "古牧" [2]=> string(0) "" } }现在要给这个数组新增">
Home > Backend Development > PHP Tutorial > 二维数组中如何除去重复项呢

二维数组中如何除去重复项呢

WBOY
Release: 2016-06-13 10:13:14
Original
1008 people have browsed it

二维数组中怎么除去重复项呢
我有个array,var_dump出来的值是:
array(1) { [0]=> array(3) { [0]=> string(0) "" [1]=> string(4) "古牧" [2]=> string(0) "" } }
现在要给这个数组新增值:$info[] = $insert;
新增完了之后,我想去除掉重复的项 不希望同样的项有两条
我用array_unique($info)不管用呢 请问怎么去重呢?
就是如果还有个项是{"","古牧",""}

就只要一项 或者新增的时候就判断

------解决方案--------------------

PHP code
function array_multiunique($ar) {  $t = array_map('serialize', $ar);  $t = array_unique($t);  return array_map('unserialize', $t);}   $ar = array(  array("","古牧",""),  array("","古牧",""),);print_r(array_multiunique($ar));<div class="clear">
                 
              
              
        
            </div>
Copy after login
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