Read the documentation exactly. The set of values that are present in $a1
and not present in $a2
is empty: $a1
just contains one element (31001
), which is also present in $a2
.
You want to get all values that are present in $a2
, but not in $a1
, so you have to switch the order of the arrays, you pass to array_diff()
:
$diff = array_diff($a2, $a1);