note 89367 added to function.array-intersect
| From: | chris at osu1 dot php dot net | Date: | Wed, 04 Mar 2009 21:06:29 +0000 |
| Subject: | note 89367 added to function.array-intersect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151484@lists.php.net to get a copy of this message | ||
Is there a simple way to find the intersection of arrays which are in an array?
There is an array, which contains an undetermined amount of arrays, and I need to array_intersect()
those arrays.
$masterAr = array(
array(1,3,7,8),
array(3,6,8,17,5,7,83),
array(4,8,3),
...
)
I would need the solution to return array(8,3) for the above example.
array_intersect($master[0], $master[1] ...)
is not possible, since it is unknown how many elements it will contain.
And of course, I could create an array_filter function... but that's much dirtier. If this were
a feature request, I would vote for simply passing one array to this function, and having it check
if the elements are arrays.
Thanks!
----
Server IP: 69.147.83.197
Probable Submitter: 74.192.3.130
----
Manual Page -- http://www.php.net/manual/en/function.array-intersect.php
Edit -- https://master.php.net/note/edit/89367
Del: integrated -- https://master.php.net/note/delete/89367/integrated
Del: useless -- https://master.php.net/note/delete/89367/useless
Del: bad code -- https://master.php.net/note/delete/89367/bad+code
Del: spam -- https://master.php.net/note/delete/89367/spam
Del: non-english -- https://master.php.net/note/delete/89367/non-english
Del: in docs -- https://master.php.net/note/delete/89367/in+docs
Del: other reasons-- https://master.php.net/note/delete/89367
Reject -- https://master.php.net/note/reject/89367
Search -- https://master.php.net/manage/user-notes.php