note 86559 added to function.array-pop
| From: | mcgroovin at gmail dot com | Date: | Thu, 23 Oct 2008 19:13:12 +0000 |
| Subject: | note 86559 added to function.array-pop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145665@lists.php.net to get a copy of this message | ||
I wrote a simple function to perform an intersect on multiple (unlimited) arrays.
Pass an array containing all the arrays you want to compare, along with what key to match by.
function multipleArrayIntersect($arrayOfArrays, $matchKey)
{
$compareArray = array_pop($arrayOfArrays);
foreach($compareArray AS $key => $valueArray){
foreach($arrayOfArrays AS $subArray => $contents){
if (!in_array($compareArray[$key][$matchKey], $contents)){
unset($compareArray[$key]);
}
}
}
return $compareArray;
}
----
Server IP: 209.41.74.194
Probable Submitter: 69.64.139.5
----
Manual Page -- http://www.php.net/manual/en/function.array-pop.php
Edit -- https://master.php.net/note/edit/86559
Del: integrated -- https://master.php.net/note/delete/86559/integrated
Del: useless -- https://master.php.net/note/delete/86559/useless
Del: bad code -- https://master.php.net/note/delete/86559/bad+code
Del: spam -- https://master.php.net/note/delete/86559/spam
Del: non-english -- https://master.php.net/note/delete/86559/non-english
Del: in docs -- https://master.php.net/note/delete/86559/in+docs
Del: other reasons-- https://master.php.net/note/delete/86559
Reject -- https://master.php.net/note/reject/86559
Search -- https://master.php.net/manage/user-notes.php