循环和AND条件子句

I have had a hard time to get my head around this little piece of code.

protected function compressLowest($lowest){
   $result = array();
   $result['morning'] = array();
   $result['afternoon'] = array();
   $result['evening'] = array();
   $result['allDay'] = array();
   $type = $this->prices->getCondType();
   $lastDate = 0;
   $i = array();
   $i['morning'] = $i['afternoon'] = $i['evening'] = $i['allDay'] = 0;

   foreach($lowest as $date => $prices){
       foreach($prices as $range => $price) {
           if($this->isNextDay($date, $result[$range][$i[$range]]['to']) && $result[$range][$i[$range]]['price'] == $price){
               $result[$range][$i[$range]]['to'] = $date;
           } else {
               $i[$range] = count($result[$range]);
               $result[$range][] = array();
               $result[$range][$i[$range]]['from'] = $date;
               $result[$range][$i[$range]]['to'] = $date;
               $result[$range][$i[$range]]['price'] = $price;
       $result[$range][$i[$range]]['destime']=$this->arr['destime'];
       $result[$range][$i[$range]]['deptime']=$this->arr['deptime'];
       $result[$range][$i[$range]]['flight']=$this->arr['flight'];
           }
       }
       $lastDate = $date;
   }
//print_r($result);exit();
   return $result;

}

And IsNextDay is checked as follows

protected function isNextDay($next, $day){
       if($next - $day == 86400){  //60*60*24 = 86400
           return true;
       } else {
           return false;
       }
   }

I can't figure out what is isNextDay($date, $result[$range][$i[$range]]['to']) && $result[$range][$i[$range]]['price'] == $price) supposed to mean (the $day thing)? in the if conditional clause of the second for-loop in the above function. Thank you if you could help me understand.

UPDATE *Sorry I hadn't read it carefully until I discovered there was ) after the result[][]['to']... thanks for your concern.*

For the source code above, I always have a notice of UNDEFINED OFFSET 0. How to fix this bug-to-be ?

for your Undefined Offset 0 at the if line some index evaluates to 0 and the array you are using that index on does not have an element at that index.

For instance (I won't list all the possibilities) if $range is 0 and $result[0] is non-existent.