Re: PHP array unions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In PHP the array is in fact a hash map, but especially it is _used_ for nearly everything map-, set-, ...-like thing. So in short: The is no operator or built-in function, that merges two arrays _and_ treat them as set (instead of the hashmap, what they are). Your solution is the way to go.

Regards,
Sebastian

Am 12.09.2012 17:10, schrieb Adam Richardson:
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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux