check same number in array in php code example
Example 1: check if all values in array are equal php
if(count(array_unique($array)) === 1) {
// all values in $array are the same
} else {
// at least 1 value in $array is different
}
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
}