Home > php教程 > php手册 > php二维数组去除特定键的重复项

php二维数组去除特定键的重复项

WBOY
Release: 2016-06-08 08:49:49
Original
799 people have browsed it

php二维数组去除特定键的重复项 无 //二维数组去除特定键的重复项 public function array_unset($arr,$key){ //$arr-传入数组 $key-判断的key值 //建立一个目标数组 $res = array(); foreach ($arr as $value) { //查看有没有重复项 if(isset($res[$value[$ke

php二维数组去除特定键的重复项
//二维数组去除特定键的重复项
    public function array_unset($arr,$key){   //$arr->传入数组   $key->判断的key值
        //建立一个目标数组
        $res = array();      
        foreach ($arr as $value) {         
           //查看有没有重复项
           if(isset($res[$value[$key]])){
                 //有:销毁
                 unset($value[$key]);
           }
           else{
                $res[$value[$key]] = $value;
           }
        }
        return $res;
    }
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template