Below are the 2 arrays
$full = array('ABCD19ed81424931667', 'ABCD0c08b1424947569');
$filtered = array('ABCD19ed81424931667');
I want the records which are not matching in 2 arrays. I have tried array_diff
, array_diff_assoc
functions it did not work for me.
array_diff
returns the difference in 1 direction. To get the difference in both directions you can do 2 array_diff
followed by a array_merge
:
$output = array_merge(array_diff($full, $filtered), array_diff($filtered, $full));
array_diff — Computes the difference of arrays.
Here array_diff(A,B) and array_diff(B,A) is different.
$full = array('ABCD19ed81424931667', 'ABCD0c08b1424947569');
$filtered = array('ABCD19ed81424931667');
$result = array_merge(array_diff($full, $filtered), array_diff($filtered, $full));
array_diff(A,B) returns all elements from A, which are not elements of B (= A without B). so you need to merge output