How to check if all values in array are the same in PHP

1 Answer

0 votes
$array = [2, 2, 2, 2, 2];

if (count(array_unique($array)) === 1) {
    echo "yes";
} else {
    echo "no";
}





/*
run:

yes

*/

 



answered Dec 5, 2023 by avibootz
...