The value "red" is not returned because in $array1 it's key is 2 while the key of "red "in $array2 it is 1.
In our example you see that only the pair "a" = "green" is present in both arrays and thus is returned. The value "red" is not returned because in $array1 it's key is 2 while the key of "red" in $array2 it is 1.