From: bob dot siefkes at packardbell dot com Operating system: XP SP2 PHP version: 5.0.4 PHP Bug Type: Output Control Bug description: array_diff depending on element sequence
Description: ------------ Behavor of array_diff is dependent on the sequence of the elements in the array. See $array2 where I changed the sequence of "a"=>"c" with "a"=>"d" and it results in different output. Be noted that the key of both elements is the same, still I would not expect array_diff to take this into account. Bob Reproduce code: --------------- // source 1 $array1 = array("a" => "c", "b" => "b" ); $array2 = array("a" => "c", "a" => "d" ); $result = array_diff($array1, $array2); // source 2 $array1 = array("a" => "c", "b" => "b" ); $array2 = array("a" => "d", "a" => "c" ); $result = array_diff($array1, $array2); Expected result: ---------------- // result1: Array ( [a] => c [b] => b ) // result2 Array ( [b] => b ) Actual result: -------------- // for both I would expect Array ( [b] => b ) -- Edit bug report at http://bugs.php.net/?id=33854&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33854&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33854&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33854&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33854&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33854&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33854&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33854&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33854&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33854&r=support Expected behavior: http://bugs.php.net/fix.php?id=33854&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33854&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33854&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33854&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33854&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33854&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33854&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33854&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33854&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33854&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33854&r=mysqlcfg