Bug #16715 Updated: array_unique results in only one entry in the array

From: Date: Sat, 22 Jun 2002 12:26:52 +0000
Subject: Bug #16715 Updated: array_unique results in only one entry in the array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-11780@lists.php.net to get a copy of this message
ID: 16715 Updated by: venaas@php.net Reported By: tlieske@thl-consulting.com -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: linux PHP Version: 4.1.2 New Comment: array_unique() doesn't work with array of arrays since all entries are compared as strings. As a string an array is represented as just "Array". Try say echo array(1,2); See comments in manual for possible work-around. If the string representation was say serialize(...) ... You are right that it worked before, but not comparing all entries as strings had some serious side-effects. If you or others want it to support arrays, you could try to implement it or file a feature request. Since this is not a bug, in my opinion, I'm classifying it as bogus, although you are correct in your description. Previous Comments: ------------------------------------------------------------------------ [2002-04-20 14:53:42] tlieske@thl-consulting.com The following code should demonstrate that unusual behavior (becaue I'm still not convinced that this is a bug) $input = array ( array (1,1), array (1,2), array(1,2), array(1,1) ); $result = array_unique ($input); print_r($result); The result is : Array ( [0] => Array ( [0] => 1 [1] => 1 ) ) This was not what I was expecting. I was expecting the following result : Array ( [0] => Array ( [0] => 1 [1] => 1 ) [1] => Array ( [0] => 1 [1] => 2 ) ) This is the result You get if You use PHP Version 4.0.4pl1 and before for example. So it is up to You, if You call this a bug or if I just have missused the function array_unique because I was not using a one dimensional array. Hopefully that helps You and me. Cheers Thomas ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16715&edit=1

« previous php.bugs (#11780) next »