note 84286 added to function.array-intersect

From: Date: Mon, 07 Jul 2008 22:57:48 +0000
Subject: note 84286 added to function.array-intersect
Groups: php.notes 
Request: Send a blank email to php-notes+get-141252@lists.php.net to get a copy of this message
A clearer example of the key preservation of this function: <?php $array1 = array(2, 4, 6, 8, 10, 12); $array2 = array(1, 2, 3, 4, 5, 6); var_dump(array_intersect($array1, $array2)); var_dump(array_intersect($array2, $array1)); ?> yields the following: array(3) { [0]=> int(2) [1]=> int(4) [2]=> int(6) } array(3) { [1]=> int(2) [3]=> int(4) [5]=> int(6) } This makes it important to remember which way round you passed the arrays to the function if these keys are relied on later in the script. ---- Server IP: 117.104.160.194 Probable Submitter: 150.101.68.60 ---- Manual Page -- http://www.php.net/manual/en/function.array-intersect.php Edit -- https://master.php.net/note/edit/84286 Del: integrated -- https://master.php.net/note/delete/84286/integrated Del: useless -- https://master.php.net/note/delete/84286/useless Del: bad code -- https://master.php.net/note/delete/84286/bad+code Del: spam -- https://master.php.net/note/delete/84286/spam Del: non-english -- https://master.php.net/note/delete/84286/non-english Del: in docs -- https://master.php.net/note/delete/84286/in+docs Del: other reasons-- https://master.php.net/note/delete/84286 Reject -- https://master.php.net/note/reject/84286 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141252) next »