php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12789 array_unique() always returns only 1 result for multi-dimentional arrays
Submitted: 2001-08-16 07:45 UTC Modified: 2001-09-14 19:42 UTC
From: bystruev at yahoo dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.6 OS: Cobalt Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
7 + 29 = ?
Subscribe to this entry?

 
 [2001-08-16 07:45 UTC] bystruev at yahoo dot com
array_unique() always returns only 1 result for multi-dimentional arrays

Here is the code:

$temp = Array (
	Array('a', 'b'),
	Array('x', 'y'),
); 
print_r($temp); 
print_r(array_unique($temp)); 

Here is the result in PHP 4.0.4, as it should be, i.e. no array change:

Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [0] => x
            [1] => y
        )

)
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [0] => x
            [1] => y
        )

)

Here is the result in PHP 4.0.6:

Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

    [1] => Array
        (
            [0] => x
            [1] => y
        )

)
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b
        )

)

I have put the code at http://www.99servers.com/develop/test/array_unique.php, you can see the results by yourself.

My phpinfo() is located at http://www.99servers.com/develop/test/phpinfo.php, just in case you need additional details about my php 4.0.6 configuration.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-14 19:40 UTC] jeroen@php.net
Array_unique isn't supposed to handle multi-dimension strings, nor objects.

See also 10658
 [2001-09-14 19:42 UTC] jeroen@php.net
Err: Array_unique/array_diff/array_intersect isn't supposed to handle multi-dimension _arrays_, nor objects.

See also 10658

 [2002-01-24 01:29 UTC] james at ractive dot ch
I think you should mention that in the manual, esp. because array_unique worked with multi-dimensional arrays for versions < 4.0.6

I was wondering today why my search script did now work anymore until i saw that my host updated to 4.1.1...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC