note 120099 added to function.array-intersect
| From: | turabgarip at gmail dot com | Date: | Sat, 29 Oct 2016 15:02:44 +0000 |
| Subject: | note 120099 added to function.array-intersect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206983@lists.php.net to get a copy of this message | ||
The reason that this function is considerably slow; is because it's comparing not only the
values cross wise; but it also compares the array's own elements too.
For example you have two arrays like;
<?php
$arr1 = array('green', 'blue', 'black');
$arr2 = array('yellow', 'red', 'cyan');
array_intersect($arr1, $arr2);
?>
Intersection will start to compare from the first three colors like; "blue" to
"green", "black" to "blue"; that are, the elements of the first array
only, and yes, comparison order is arbitrary, but always in the same order.
It will do the same for the second array too.
----
Server IP: 72.52.91.14
Probable Submitter: 31.155.70.152
----
Manual Page -- http://php.net/manual/en/function.array-intersect.php
Edit -- https://master.php.net/note/edit/120099
Del: integrated -- https://master.php.net/note/delete/120099/integrated
Del: useless -- https://master.php.net/note/delete/120099/useless
Del: bad code -- https://master.php.net/note/delete/120099/bad+code
Del: spam -- https://master.php.net/note/delete/120099/spam
Del: non-english -- https://master.php.net/note/delete/120099/non-english
Del: in docs -- https://master.php.net/note/delete/120099/in+docs
Del: other reasons-- https://master.php.net/note/delete/120099
Reject -- https://master.php.net/note/reject/120099
Search -- https://master.php.net/manage/user-notes.php