📌  相关文章
📜  php 检查所有数组值是否相同 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:20.136000             🧑  作者: Mango

代码示例3
1. Check if all values are equal without knowing the values from array:
$array = array('true', 'true', 'true');
if((count(array_unique($array)) === 1)) {
  echo "all equal";
} else {
  echo "not equal";
}

2. Check if all values are equal when you know the value from array:
- In this case we know the equal value should be "true" 
$array = array('true', 'true', 'true');
if (count(array_unique($array)) === 1 && end($array) === 'true') {
}