find the different number in an array php code example
Example 1: array_diff
<?php
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);
?>
Array
(
[1] => blue
)
Example 2: check if any values are the same in an array php
if(count(array_unique($array, SORT_REGULAR)) < count($array)) {
// $array has duplicates
} else {
// $array does not have duplicates
}