Compares array against one or more other arrays and returns the values in array that are not present in any of the other arrays.
Compares array against one or more other arrays and returns the values in array that are not present in any of the other arrays.
function
{{$diff = array_diff($array1, $array2,...)}}
Examples
{{$array1 = ['green', 'red', 'blue']}}
{{$array2 = ['green', 'yellow', 'red']}}
{{$diff = array_diff($array1, $array2)}}
{{$diff|print_r}}
Outcome:
Array ( [2] => blue )
Outcome based on the first array
The outcome is based on the differences between the first array in relation to the other arrays. As a result, only the value 'blue' appears and not the value 'yellow,' as it does not occur in the first array.