Tommy Lee Tommy Lee - 1 year ago 70
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

Answer Source

Hope this can help.

array_unique doc

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download