Hi i want to compare all the values of 2 arrays and end up with a true or false . I am using the code below and would of thought that the result would be false . but that is
array_diff gives which elements are in $before
but not $after
. Since both arrays consist of '0'
and '1'
, it returns an empty array.
What you're looking for is array_diff_assoc, which looks at keys and values together.
Do note, the output you get will not be Array( [0] => 0 )
, but rather Array( [0] => 1 )
, as it gives the elements from the first array that doesn't exist in the other one.
If you wish the other output, you'll need to do array_diff_assoc($after, $before)
.