views:

36

answers:

2

How would I compare 2 Arrays in PHP to find which values each array have in common.

Example would be

Array 1

Array
(
    [0] => ace
    [1] => one
    [2] => five
    [3] => nine
    [4] => elephant
)

Array 2

Array
(
    [0] => elephant
    [1] => seven
    [2] => ace
    [3] => jack
    [4] => queen
)

Output Array ( [0] => ace [1] => elephant )

+2  A: 

array_intersect function can do this.

Vincent Savard