|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-10-21 14:28 UTC] venaas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 08:00:01 2025 UTC |
The function array_intersect() does change the order of the elements that are returned from array in first parameter. Since "order" is an essential feature of arrays it would be inconsistent to change it implicitely. Seems to be weak implementation of array_intersect(). (At least it should be documented, but i think it should be fixed) I don't checked the other array-functions for this behavior, it could be that some show this inconsistency, too. The resulting array seems to be in order of the contained values. In my example, the resulting array is alphabetically sorted: ---- code snippet ---- // result of array_intersect() is ex $a = array(1=>'c',2=>'z',666=>'b',4=>'a'); $b = $a; var_dump(array_intersect($a,$b)); ---- result ---- array(4) { [4]=> string(1) "a" [666]=> string(1) "b" [1]=> string(1) "c" [2]=> string(1) "z" }