Bug #79426 [Nab]: array_unique bad results

From: Date: Sat, 28 Mar 2020 23:26:53 +0000
Subject: Bug #79426 [Nab]: array_unique bad results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226303@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79426&edit=1 ID: 79426 User updated by: dpfender44 at gmail dot com Reported by: dpfender44 at gmail dot com Summary: array_unique bad results Status: Not a bug Type: Bug Package: Arrays related Operating System: windows 10 PHP Version: 7.4.4 Block user comment: N Private report: N New Comment: In this case there are no keys in the array. It is an array of elements that are just simple strings where each has a numeric index provided by PHP when the element is assigned to the array. The resulting array also contains many elements that have unset values and produce errors of bad index when attempting access thru the array sequentially with successive numeric indexes. If the count of elements in the array shows 30 elements, then each element index 0 thru 29 should have a value. Otherwise, the new array makes no sense. Previous Comments: ------------------------------------------------------------------------ [2020-03-28 22:46:29] requinix@php.net > Note that keys are preserved. If multiple elements compare equal under the given > sort_flags, then the key and value of the first equal element will be retained. ------------------------------------------------------------------------ [2020-03-28 18:28:18] dpfender44 at gmail dot com How is this not a bug? The original array contains string values and the result is not correct. This is not a complicated situation. Is there a flag that is need to make this simple case work as the documentation implies that it should? If so, then the documentation should be improved. ------------------------------------------------------------------------ [2020-03-28 15:39:15] peehaa@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ------------------------------------------------------------------------ [2020-03-28 15:36:12] dpfender44 at gmail dot com Description: ------------ The function array_unique produces bad results with an array of simple string values. Many unset elements result in the new array. The test program shows good results with my own do_array_unique function and bad results with PHP array_unique. Test script: --------------- http://shuffle.djpnet.dyndns.org/shuffle3_php.txt ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79426&edit=1

« previous php.bugs (#226303) next »