Compare Php Array Elements Function
What is array_diff Function?
Explanation
The "array_diff" function computes the difference of arrays.
Syntax:
array_diff (array1,array2,array3.....)
In the above syntax "array1" is the array to be compare with the values of "array2", and display the difference as the result.
Example :
<?php
$a = array("a" => "green", "red", "blue", "red");
$b = array("b" => "green", "yellow", "red");
$result = array_diff($a,$b);
print_r($result);
?>
Result :
Array
(
[1] => blue
)
In the above example array "$a" is compared with array "$b" , the only elements that is not present in the array "$b" is "blue".