//假如 数据是这样的
     
    $arr=[
       [
      'goods_name'=>'xxx',
      'goods_id'=>111,
    ],
    [
    'goods_name'=>'xxx',
      'goods_id'=>123,
    
    ],
    [
    'goods_name'=>'xxx',
    'goods_id'=>'123'
    ],
    ];
    
      function array_unset_tt($arr,$key='goods_id'){
        //建立一个目标数组
        $res = array();
        foreach ($arr as $value) {
            //查看有没有重复项
            if(isset($res[$value[$key]])){
                unset($value[$key]);  //有:销毁
            }else{
                $res[$value[$key]] = $value;
            }
        }
        return $res;
    }
     
    //调用方法处理后,就把重复的goods_id的数组过滤,只剩下一个!!!开心吗?
转载于:https://www.cnblogs.com/guoshuai-yangxu/p/10876130.html