0

i just wanted to know whether array_unique be used for multi dimensional arrays

codaddict
  • 445,704
  • 82
  • 492
  • 529
Anish Joseph
  • 1,026
  • 3
  • 10
  • 24

5 Answers5

2

From the docs:

Note that array_unique() is not intended to work on multi dimensional arrays.

jwueller
  • 30,582
  • 4
  • 66
  • 70
1

From php.net's page on array_unique

Note: Note that array_unique() is not intended to work on multi dimensional arrays

The Archetypal Paul
  • 41,321
  • 20
  • 104
  • 134
0

array_unique() is not intended to work on multi dimensional arrays.

Shaun Hare
  • 3,771
  • 2
  • 24
  • 36
0

just go here http://php.net/manual/en/function.array-unique.php and read this "Note: Note that array_unique() is not intended to work on multi dimensional arrays"

TomaszSobczak
  • 2,900
  • 21
  • 24
-1
<?php

$array = array(
    array(
        'id'    => 123,
        'name'  => 'Some Product',
        'ean'   => '1234567890123'
    ),
    array(
        'id'    => 123,
        'name'  => 'Some Product',
        'ean'   => '4852950174938'
    ),
    array(
        'id'    => 123,
        'name'  => 'Some Product',
        'ean'   => '1234567890123'
    ),
);
$uniqueArray = array_unique($array);
var_dump($uniqueArray);
?>

Output

array(1) {
  [0]=>
  array(3) {
    ["id"]=>
    int(123)
    ["name"]=>
    string(12) "Some Product"
    ["ean"]=>
    string(13) "1234567890123"
  }
}

Please see that http://php.net/manual/en/function.array-unique.php

Pradeep Singh
  • 3,582
  • 3
  • 29
  • 42