array and operations with others array

two array
A) 1, 2, 3, 4, 5, 6
B) 4, 6, 9

how can to have an array
C) 4, 6
all the B's values that have value in A

and
an array
D) 1, 2, 3, 4, 5, 6, 9
a simple union of A + B with no duplicates values
artev [ Sa, 23 Juni 2007 12:16 ] [ ID #1746710 ]

Re: array and operations with others array

On Sat, 23 Jun 2007 12:16:34 +0200, artev <mailnotspammm [at] notspamm.nn>
wrote:

> two array
> A) 1, 2, 3, 4, 5, 6
> B) 4, 6, 9
>
> how can to have an array
> C) 4, 6
> all the B's values that have value in A

array_intersect($a,$b);

> and
> an array
> D) 1, 2, 3, 4, 5, 6, 9
> a simple union of A + B with no duplicates values

array_unique(array_merge($a,$b));

--
Rik Wasmus
luiheidsgoeroe [ Sa, 23 Juni 2007 17:07 ] [ ID #1746713 ]
PHP » alt.php » array and operations with others array

Vorheriges Thema: imagerotate problem with PHP 4.3.9 - PHP 5.2.0 using GD2
Nächstes Thema: Teknologiaplaneetta - Enterprise Solution