Bug #14805: array_unique works opposed to the manual

From: Date: Wed, 02 Jan 2002 17:48:29 +0000
Subject: Bug #14805: array_unique works opposed to the manual
Groups: php.dev 
Request: Send a blank email to php-dev+get-75615@lists.php.net to get a copy of this message
From:             pgerzson@freestart.hu
Operating system: MS Windows 98
PHP version:      4.0.6
PHP Bug Type:     Arrays related
Bug description:  array_unique works opposed to the manual

The manual (recent version from cvs) states that :

" array_unique() will keep the first key encountered for  every value, and
ignore all following keys. "

I've tested the two examples in this page and I've found
this statement is not true.

<?php
$input = array (4,"4","3",4,3,"3");
$result = array_unique ($input);
var_dump($result);
?>

output: /* PHP 4.0.6 Win'98 PWS */
array(2) {
  [3]=>
  int(4)
  [4]=>
  int(3)
}

but the manual says it should print:

array(2) {
   [0]=>
   int(4)
   [1]=>
   string(1) "3"
}

As you can recognize the latest keys are preserved
for both value 4 and 3.

-- 
Edit bug report at: http://bugs.php.net/?id=14805&edit=1



Thread (5 messages)

« previous php.dev (#75615) next »