快乐每一天

自己选择的路,跪着也要走下去...

PHP二维数组去重,最简单的方法

<?php
 
/*二维数组去掉重复值*/
 
$cc=array(
 '0' => 
  array (
    'wx_nickname' => '江淮智库',
    'wx_name' => 'anhui-sky',
    'url_times' => '0'
  ),
  '1' => 
  array (
    'wx_nickname' => '安徽发布',
    'wx_name' => 'anhuifabu',
    'url_times' => '0'
  ),
  '2' => 
  array (
    'wx_nickname' => '安徽发布',
    'wx_name' => 'anhuifabu',
    'url_times' => '0'
  )
);
 
 
$ee=[];
 
foreach ($cc as $k => $v) {
    if (!in_array($v['wx_nickname'],$ee)) {
        $ff[]=$v;
        $ee[]=$v['wx_nickname'];
    }
}
var_dump($ff);
?>
此文章共有条评论, 人参与 |Powerd By Angboo