view raw
Tommy Lee Tommy Lee - 7 months ago 37
PHP Question

PHP comparing array elements as a whole

For example I have two arrays,

$arrayA = [0=>"A", 1=>"B", 2=>"C", 3=>"C", 4=>"E", 5=>"F"];
$arrayB = [0=>"B", 1=>"C"];

If I use array_intersect():

$same = array_intersect($arrayA, $arrayB);

I will get the result of

1 => B
2 => C
3 => C

Instead, what I want to achieve is to get only

1 => B
2 => C


Hope this can help.

array_unique doc