0

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

3
  • @Karl In php just like its tagged :) Commented Dec 6, 2010 at 12:16
  • 1
    @tomaszsobczak: If you look closely at the time, the PHP-tag was added after he asked that ;) Commented Dec 6, 2010 at 12:18
  • @elusive - my fault, sorry :) Commented Dec 6, 2010 at 13:55

5 Answers 5

2

From the docs:

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

Sign up to request clarification or add additional context in comments.

Comments

1

From php.net's page on array_unique

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

Comments

0

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

Comments

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"

Comments

-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.