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

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -