php array deduplication

The php two-digit array is deduplicated, and the one-dimensional and two-digit arrays are the same to be deduplicated

Paste the code directly

 1 function ArrayUniq($data){
 2     $tmp = array();
 3     foreach($data as $key => $value){
 4         foreach($value as $key1 => $value1){
 5             $value[$key1] = $key1 . '_|_' . $value1;
 6         }
 7         $tmp[$key] = implode(',|,', $value);
 8     }
 9     $tmp = array_unique($tmp);
10     $result = array();
11     foreach($tmp as $tmp_v){
12         $tmp_v2 = explode(',|,', $tmp_v);
13         $tmp_v3 = array();
14         foreach($tmp_v2 as $v2){
15             $v2 = explode('_|_', $v2);
16             $tmp_v3[$v2[0]] = $v2[1];
17         }
18         array_push($result, $tmp_v3);
19     }
20     return $result;
21 }

 

test code

reserved

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324660688&siteId=291194637