PHP 去除二維陣列重複值

2021-08-26 23:06:24 字數 3159 閱讀 5597

public function remove_duplicate($data)

}if(!$res)

}return $arr;

}

插入入二位陣列。根據每個陣列中的id然後剔除每個陣列中的重複陣列

未處理前的陣列

array

([0] => array

([id] => 67

[pid] => 69

[name] => admin/authgroup/getauthgroup

[menu_name] => /permissions/root

[icon] => 

[title] => 許可權組

[type] => 1

[sort] => 2

[hide] => 2

[status] => 1

[ctime] => 1535709040

[utime] => 1535709143

)[1] => array

([id] => 68

[pid] => 69

[name] => admin/authrule/getauthrule

[menu_name] => /permissions/rootmenu/0

[icon] => 

[title] => 許可權選單

[type] => 1

[sort] => 2

[hide] => 2

[status] => 1

[ctime] => 1535709276

[utime] => 1535709325

)[2] => array

([id] => 69

[pid] => 65

[name] => 

[menu_name] => 

[icon] => el-icon-setting

[title] => 許可權管理

[type] => 2

[sort] => 2

[hide] => 1

[status] => 1

[ctime] => 1535714086

[utime] => 

)[3] => array

([id] => 65

[pid] => 0

[name] => 

[menu_name] => 

[icon] => 

[title] => 許可權管理模組

[type] => 2

[sort] => 2

[hide] => 1

[status] => 1

[ctime] => 1535708593

[utime] => 

)[4] => array

([id] => 65

[pid] => 0

[name] => 

[menu_name] => 

[icon] => 

[title] => 許可權管理模組

[type] => 2

[sort] => 2

[hide] => 1

[status] => 1

[ctime] => 1535708593

[utime] => 

)[5] => array

([id] => 65

[pid] => 0

[name] => 

[menu_name] => 

[icon] => 

[title] => 許可權管理模組

[type] => 2

[sort] => 2

[hide] => 1

[status] => 1

[ctime] => 1535708593

[utime] => 

)處理後的陣列:

array

([0] => array

([id] => 67

[pid] => 69

[name] => admin/authgroup/getauthgroup

[menu_name] => /permissions/root

[icon] => 

[title] => 許可權組

[type] => 1

[sort] => 2

[hide] => 2

[status] => 1

[ctime] => 1535709040

[utime] => 1535709143

)[1] => array

([id] => 68

[pid] => 69

[name] => admin/authrule/getauthrule

[menu_name] => /permissions/rootmenu/0

[icon] => 

[title] => 許可權選單

[type] => 1

[sort] => 2

[hide] => 2

[status] => 1

[ctime] => 1535709276

[utime] => 1535709325

)[2] => array

([id] => 69

[pid] => 65

[name] => 

[menu_name] => 

[icon] => el-icon-setting

[title] => 許可權管理

[type] => 2

[sort] => 2

[hide] => 1

[status] => 1

[ctime] => 1535714086

[utime] => 

)[3] => array

([id] => 65

[pid] => 0

[name] => 

[menu_name] => 

[icon] => 

[title] => 許可權管理模組

[type] => 2

[sort] => 2

[hide] => 1

[status] => 1

[ctime] => 1535708593

[utime] => ))

PHP一維 二維陣列去除重複

生活也許就是按照自己的節奏生活,不用在意他人的眼光。木木 題記 php陣列去除重複項有個內建函式array unique 但是php的array unique函式只適用於一維陣列,對多維陣列並不適用,以下提供乙個二維陣列的array unique函式。二維陣列去掉重複值 function array...

php二維陣列 去重複的值

方法一 function arrayhandle array temp array unique temp 去掉重複的字串,也就是重複的一維陣列值 foreach temp as key v return temp 方法二 public function arrayhandle datas 去掉重複...

PHP二維陣列 去除指定列含有重複項的陣列

arr array 0 array 張三 2,3,4 1 array 李四 2,3,4 2 array 張三 2,4,3 去除第一列含有 張三 的重複項陣列 源 header content type text html charset utf 8 去除指定列含有重複項的陣列 arr array 0...