|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-25 21:26 UTC] bob dot siefkes at packardbell dot com
[2005-07-25 22:32 UTC] iliaa@php.net
[2005-07-26 08:38 UTC] bob dot siefkes at packardbell dot com
[2005-07-26 12:54 UTC] mgf@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 26 04:00:02 2025 UTC |
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 )