phparraysfilterassociative-arrayarray-difference

Count the differences between two flat, associative arrays


Array ( [34] => A [35] => B [36] => B [37] => C ) //This is the Answer

Compares

Array ( [34] => B [35] => C [36] => A [37] => D ) //This is the right data

I have tried array_diff_key and array_diff functions but both only returns

Array()

I would like to get the count of the difference, is there a faster way? What did I do wrong?


Solution

  • count(array_diff_assoc($array1, $array2));