How to check if all values in array are equal in PHP

Snippet

The easiest way to check the values of an array contain the same value using array_unique and count if all keys are the same this should equal 1.

downloadcopy
<?php
$arr = array('test', 'test', 'test');
if (count(array_unique($arr)) === 1) {
    echo 'equal';
} else {
    echo 'not equal';
}