There are 3 operations with sets in mathematics: intersection, difference and union (unification). In PHP we can do this operations with arrays:
array_unique( array_merge( ... ) )