note 88748 deleted from function.array-intersect by danbrown
| From: | danbrown@php.net | Date: | Thu, 05 Feb 2009 20:52:52 +0000 |
| Subject: | note 88748 deleted from function.array-intersect by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150271@lists.php.net to get a copy of this message | ||
Note Submitter: Maikel
----
About Malte post, this way is quite little better
<?php
$firstarray = array(1, 1, 2, 3, 4, 1);
$secondarray = array(4, 1, 6, 5, 4, 1);
//array_intersect($firstarray, $secondarray): 1, 1, 1, 4
foreach ($firstarray as $key=>$value){
if (($key = array_search($value,$secondarray)) !== FALSE){
unset($secondarray[$key]);
}
}
//$firstarray: 1, 1, 4
?>