php check if all values in array are equal

80

// All values are equal
if (count(array_unique($allvalues)) === 1 && end($allvalues) === 'true') {

}

// Check the thing you don't want
if (in_array('false', $allvalues, true)) {

}
$allvalues = array('true', 'true', 'true');
if (count(array_unique($allvalues)) === 1 && end($allvalues) === 'true') {
}

Comments

Submit
0 Comments