Advertisement
Guest User

Удаление дублей в многомерном массиве

a guest
Sep 1st, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // http://vladimir-awm.ru
  2.  
  3. function unique_multidim_array($array, $key) {
  4.       $temp_array = array();
  5.       $i = 0;
  6.       $key_array = array();
  7.  
  8.       foreach($array as $val) {
  9.             if (!in_array($val[$key], $key_array)) {
  10.                   $key_array[$i] = $val[$key];
  11.                   $temp_array[$i] = $val;
  12.             }
  13.             $i++;
  14.       }
  15.       return $temp_array;
  16. }
  17.  
  18. $all = unique_multidim_array($all,'0');
  19.  
  20. foreach ($all as $value) {
  21.       echo implode("\t", $value)."<br />";
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement