PHP:检查数组中的所有值是否都小于 x

标签 php arrays

有这个功能吗?

例如,如果我有一个像 1,1,3,2,1,2,3,2,2,3,3,2,5,1 这样的数组 当且仅当数组中的所有数字都小于 5 时,该函数才返回 true

最佳答案

if(max($yourArray) < 5) {
  //all values in array are less than 5
}

关于PHP:检查数组中的所有值是否都小于 x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6992872/

相关文章:

php - 如何知道安装的 mysqli 版本是什么?

python - 重新调整 3d numpy 数组中的值

c - 如何找到数组中元素的数量?

arrays - Swift 中的数组返回错误

php - mysql_num_rows 抛出警告并且不继续

php - array_map、array_walk 和 array_filter 的区别

php - 难题 : How to access ffmpeg_php getFrame in Imagick without convert to GD?

php - 我想数组键和数组值逗号分隔的字符串

c++ - 将数组数据插入模板

Javascript函数参数作为数组