Req #34217 [Com]: Requesting array_unique() function that works with multi-dimensional arrays.

From: Date: Tue, 04 Aug 2015 16:10:52 +0000
Subject: Req #34217 [Com]: Requesting array_unique() function that works with multi-dimensional arrays.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194953@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=34217&edit=1 ID: 34217 Comment by: cz dot paranoiq at gmail dot com Reported by: nickj-phpbugs at nickj dot org Summary: Requesting array_unique() function that works with multi-dimensional arrays. Status: Open Type: Feature/Change Request Package: Feature/Change Request Operating System: * PHP Version: 5CVS-2005-08-23 (snap) Block user comment: N Private report: N New Comment: this is still relevant for PHP 5.6 and PHP 7 i would call this rather a bug than a feature request. the actual result returned is a total nonsense and PHP generates a "Notice: Array to string conversion" for every item of array it should be either fixed or throw something stronger than a notice related bug: https://bugs.php.net/bug.php?id=62977 Previous Comments: ------------------------------------------------------------------------ [2005-08-23 10:15:03] nickj-phpbugs at nickj dot org Description: ------------ Requesting array_unique() function to work correctly with multi-dimensional arrays (or a new function that does the same thing, so as to retain backwards compatibility) Script: =================================================== <?php $array = array (1 => array(1, 2, 3), 2 => array(1, 2), 3 => array(1, 3, 4), 4 => array(1, 2), 5 => array(1, 3, 4) ); $array = array_unique ($array); print_r ($array); ?> =================================================== Current actual output: =================================================== ludo:~/tmp/php-5.1-dev/array_unique# ../../php5-200507102230/sapi/cli/php ./test.php Array ( [1] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) ludo:~/tmp/php-5.1-dev/array_unique# =================================================== Desired output: =================================================== ludo:~/tmp/php-5.1-dev/array_unique# ../../php5-200507102230/sapi/cli/php ./test.php Array ( [1] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [4] => Array ( [0] => 1 [1] => 2 ) [5] => Array ( [0] => 1 [1] => 3 [2] => 4 ) ) ludo:~/tmp/php-5.1-dev/array_unique# =================================================== Note the order of the keys isn't a big concern to me, although others may be concerned about this. Various bogus bugs that people have logged when the encountering this behaviour: Bug #16715, Bug #12690, Bug #13403, Bug #10891, Bug #12789, Bug #12528 I couldn't see a feature request for this though, so that's what this is. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=34217&edit=1

« previous php.bugs (#194953) next »