note 110544 deleted from function.array-intersect by aharvey
| From: | aharvey@php.net | Date: | Mon, 05 Nov 2012 03:18:44 +0000 |
| Subject: | note 110544 deleted from function.array-intersect by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191669@lists.php.net to get a copy of this message | ||
Note Submitter: JP
----
// set intersection of arrays. eliminates duplicates.
function array_intersection( $a1, $a2) {
$result = Array();
foreach ( $a1 as $val){
if ( (!in_array( $val, $result, true)) && in_array( $val, $a2, true)) {
$result[] = $val;
}
}
return $result;
}