note 70962 added to function.array-intersect
| From: | -dot-) | Date: | Mon, 06 Nov 2006 18:24:35 +0000 |
| Subject: | note 70962 added to function.array-intersect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119432@lists.php.net to get a copy of this message | ||
Inspired by the comments from nthitz at gmail dot com and terry(-at-)shuttleworths(-dot-)net, i did
some small tests.
As far as i can tell, it _is_ faster if you do:
<?php
$resultArray = array_intersect($smallArray, $bigArray);
?>
but, to my surprise, the fastest method seems to be:
<?php
$resultArray = array();
foreach($smallArray as $val) {
if(!in_array($val, $bigArray)) {
$resultArray[] = $val;
}
}
?>
Can someone please confirm this?
----
Server IP: 217.13.201.10
Probable Submitter: 85.183.18.14
----
Manual Page -- http://www.php.net/manual/en/function.array-intersect.php
Edit -- https://master.php.net/note/edit/70962
Del: integrated -- https://master.php.net/note/delete/70962/integrated
Del: useless -- https://master.php.net/note/delete/70962/useless
Del: bad code -- https://master.php.net/note/delete/70962/bad+code
Del: spam -- https://master.php.net/note/delete/70962/spam
Del: non-english -- https://master.php.net/note/delete/70962/non-english
Del: in docs -- https://master.php.net/note/delete/70962/in+docs
Del: other reasons-- https://master.php.net/note/delete/70962
Reject -- https://master.php.net/note/reject/70962
Search -- https://master.php.net/manage/user-notes.php