PHP array unions
| From: | Adam Richardson | Date: | Wed, 12 Sep 2012 15:10:03 +0000 |
| Subject: | PHP array unions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-319045@lists.php.net to get a copy of this message | ||
Hi!
So, PHP has the '+' array operator, which forms the union of arrays,
but it does so by key. What I'm looking for is a function that forms
the union of arrays based on value. Currently, I use code like the
following:
array_unique(array_merge($array1, $array2, $array3));
This is useful to me because I tend to program using functional
programming principles. Just want to make sure I'm not missing a core
function that already does this. If there's not a core function, I
might just build an array_union extension because the functionality is
so common in my codebases.
Thanks,
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com