php 一维数组判断值是否全部相等
$uqine = [1,2,3]
if ($uqine) {
$uq = array_unique($uqine);
foreach ($uq as $index => $item) {
if (intval($item) == 0 ) {
throw new HttpResponseException('111');
}
}
if (count($uq) > 1) {
throw new HttpResponseException('222');
}
}
php 一维数组判断值是否全部相等
最新推荐文章于 2023-11-13 22:15:00 发布
本文介绍了一种使用PHP检查一维数组中所有值是否完全相等的方法。通过array_unique函数去除重复值,再结合foreach循环和count函数,确保数组元素唯一,从而判断数组值是否全部相同。
716

被折叠的 条评论
为什么被折叠?



