且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP:检查是否在阵列中的所有值都小于X

更新时间:2022-10-16 09:13:35

  IF(MAX($ yourArray)小于5){
  //在阵列中的所有值都小于5
}

Is there a function to do this?

For example if I have an array like 1,1,3,2,1,2,3,2,2,3,3,2,5,1 The function should return true if and only if all the numbers in the array are less than 5

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