- //二维数组去除特定键的重复项
- 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;
- }
- //该片段来自于http://www.codesnippet.cn/detail/2505201512653.html
来源: http://www.codesnippet.cn/detail/2505201512653.html