php - Compare two array and get all differences -
i have 2 arrays this.
$array1=array(1,2,3,4,5,7); $array2=array(1,2,3,4,5,6); so, output should bring difference in both arrays.
the output should be.
1,2,3,4,5 -> these numbers exist in both arrays, so these should ignored.
7 , 6 -> these numbers un-common in both arrays, need these values in array.
the output should 7 & 6.
help me out. have tried array_diff , other array elements.
try this
array_merge(array_diff($array1,$array2),array_diff($array2,$array1))
Comments
Post a Comment