Re: Broken PHP4 Function

From: Date: Tue, 05 Sep 2000 01:56:08 +0000
Subject: Re: Broken PHP4 Function
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-32046@lists.php.net to get a copy of this message
"Matt G. Ellis" wrote: > 1) I am not a programer. > 2) I did not find this bug. > Okay, In PHP 4.0.2 array_unique() is broken, as noted in the documention > addenum by users, instad of creating a new array with just one copy of each > vaule, it just blanks out duplicate vaules. > As I understand it the function returns an array with just one copy of each > value, not one copy and blank spaces where the other vaules where. > If you have any info on this, please CC it to me... The docs note that the keys are preserved. Thus: $orig_array = array("zero", "one", "one", "two"); /* $orig_array is now the following: $orig_array[0] = "zero"; $orig_array[1] = "one"; $orig_array[2] = "one"; $orig_array[3] = "two"; */ $new_array = array_unique($orig_array); /* $new_array is now the following: $new_array[0] = "zero"; $new_array[1] = "one"; $new_array[2] = ""; $new_array[3] = "two"; */ The key of $orig_array[2] was preserved. I've added some clarification to the docs. -Bop -- Brought to you from iBop the iMac, a MacOS, Win95, Win98, LinuxPPC machine, which is currently in MacOS land. Your bopping may vary.

« previous php.dev (#32046) next »