Bug #17750: array_unique is not returning array[0] when all values are equal
| From: | thiago at softexpert dot com | Date: | Thu, 13 Jun 2002 17:35:38 +0000 |
| Subject: | Bug #17750: array_unique is not returning array[0] when all values are equal | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-10366@lists.php.net to get a copy of this message | ||
From: thiago@softexpert.com
Operating system: Windows 2000
PHP version: 4.2.1
PHP Bug Type: Arrays related
Bug description: array_unique is not returning array[0] when all values are equal
<?php
$array = array(0 => 8, 1 => "8", 2 => "8");
$array = array_unique($array);
print_r($array);
?>
The manual says:
=== MANUAL BEGIN ===
array_unique() takes input array and returns a new array without duplicate
values.
Note that keys are preserved. array_unique() sorts the values treated as
string at first, then will keep the first key encountered for every value,
and ignore all following keys. It does not mean that the key of the first
related value from the unsorted array will be kept.
Note: Two elements are considered equal if and only if (string) $elem1 ===
(string) $elem2. In words: when the string representation is the same.
The first element will be used.
==== MANUAL END ====
So, it should return $array[1], right ?
Its always returning the last value.
--
Edit bug report at http://bugs.php.net/?id=17750&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17750&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17750&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17750&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17750&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17750&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17750&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17750&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17750&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17750&r=globals