note 70962 deleted from function.array-intersect by nlopess
| From: | nlopess@php.net | Date: | Mon, 06 Nov 2006 18:34:40 +0000 |
| Subject: | note 70962 deleted from function.array-intersect by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-119433@lists.php.net to get a copy of this message | ||
Note Submitter: info (-at-) knusperpixel (-dot-) com
----
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?