From: djungowski at chip dot de Operating system: any PHP version: 5.2.9 PHP Bug Type: Arrays related Bug description: array_unique does not work with multidimensional arrays
Description: ------------ array_unique does not work, when it comes to multidimensional arrays. I've posted the behaviour + a workaround here: http://www.phpdevblog.net/2009/01/using-array-unique-with-multidimensional-arrays.html#comment505 I've also found the (older) bug report #12789, where Jeroen says that array_unique is not supposed to work with multidimensional arrays. If this is so, you should at least mention it in the documentation (see the older bug report! James says the same thing) Reproduce code: --------------- $array = array( array( 'id' => 123, 'name' => 'Some Product', 'ean' => '1234567890123' ), array( 'id' => 123, 'name' => 'Some Product', 'ean' => '4852950174938' ), array( 'id' => 123, 'name' => 'Some Product', 'ean' => '1234567890123' ), ); $uniqueArray = array_unique($array); var_dump($uniqueArray); Expected result: ---------------- array(2) { [0]=> array(3) { ["id"]=> int(123) ["name"]=> string(12) "Some Product" ["ean"]=> string(13) "1234567890123" } [1]=> array(3) { ["id"]=> int(123) ["name"]=> string(12) "Some Product" ["ean"]=> string(13) "4852950174938" } } Actual result: -------------- array(1) { [0]=> array(3) { ["id"]=> int(123) ["name"]=> string(12) "Some Product" ["ean"]=> string(13) "1234567890123" } } -- Edit bug report at http://bugs.php.net/?id=47642&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47642&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47642&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47642&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47642&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47642&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47642&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47642&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47642&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47642&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47642&r=support Expected behavior: http://bugs.php.net/fix.php?id=47642&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47642&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47642&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47642&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47642&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47642&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47642&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47642&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47642&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47642&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47642&r=mysqlcfg
