fork(3) download
  1. <?php
  2.  
  3. function removeduplicateKeys($data){
  4.  
  5. $_data = array();
  6.  
  7. foreach ($data as $v) {
  8. if (isset($_data[$v['ean']])) {
  9. // found duplicate
  10. continue;
  11. }
  12. // remember unique item
  13. $_data[$v['ean']] = $v;
  14. }
  15.  
  16. $data = array_values($_data);
  17. return $data;
  18.  
  19. }
  20.  
  21.  
  22. $arr =array(
  23. "0" => Array
  24. (
  25. "ean" => 6900532615069,
  26. "productPrice" => 1140,
  27. "productCount" => 5
  28. ),
  29. "1" => Array
  30. (
  31. "ean" => 6900532615069,
  32. "productPrice" => 1140,
  33. "productCount" => 50
  34. ),
  35. "2" => Array
  36. (
  37. "ean" => 6900535364122,
  38. "productPrice" => 1140,
  39. "productCount" => 50
  40. ),
  41.  
  42. "3" => Array
  43. (
  44. "ean" => 6900532615069,
  45. "productPrice" => 1140,
  46. "productCount" => 10,
  47. ));
  48.  
  49. print_r(removeduplicateKeys($arr));
Success #stdin #stdout 0.01s 82560KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [ean] => 6900532615069
            [productPrice] => 1140
            [productCount] => 5
        )

    [1] => Array
        (
            [ean] => 6900535364122
            [productPrice] => 1140
            [productCount] => 50
        )

)