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 一维数组判断值是否全部相等 $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'); } }