在有两个条件的while循环中未定义的偏移量


Undefined offset in while loop with 2 conditions

我有一个这样的数组:

array (size=3)
 0 => 
    array (size=2)
      'score' => float 17.891873624039
 1 => 
    array (size=2)
      'score' => float 17.883449353824
 2 => 
    array (size=2)
      'score' => float 4.702030124427
和像这样的while循环:
 $offset=1;
 while($scoreList[$rank+$offset]!=NULL && $scoreList[$rank]["score"]==$scoreList[$rank+$offset]["score"])
 {
    //do something
    $offset++;
 }

我需要检查数组中的下一个索引是否存在同时检查它是否等于当前对象但我得到

定义抵消:4

我不能把第二个条件放在if语句中,因为如果这两个索引相等,偏移量应该增加,所以如果我把它放在if子句中,它就会陷入无限循环。

这两个可能是有用的:)

isset(); - php.net

if(isset($value[0])){
  //DO SOMETHING IF VALUE IS SET
}
if(!isset($value[0])){
  //DO SOMETHING IF VALUE ISN'T SET
}

empty(); - php.net

if(empty($value[0])){
  //DO SOMETHING IF VALUE / VARIABLE DOESN'T EXIST
}
if(!empty($value[0])){
  //DO SOMETHING IF VALUE / VARIABLE DOES EXIST AND ISN'T EMPTY
}