Loop and AND conditional clause
<p>I have had a hard time to get my head around this little piece of code.    </p>

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

   foreach($lowest as $date =&gt; $prices){
       foreach($prices as $range =&gt; $price) {
           if($this-&gt;isNextDay($date, $result[$range][$i[$range]]['to']) &amp;&amp; $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-&gt;arr['destime'];
       $result[$range][$i[$range]]['deptime']=$this-&gt;arr['deptime'];
       $result[$range][$i[$range]]['flight']=$this-&gt;arr['flight'];
           }
       }
       $lastDate = $date;
   }
//print_r($result);exit();
   return $result;
</code></pre>

<p>}</p>

<p>And IsNextDay is checked as follows   </p>

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

<p>I can't figure out what is 
<code>isNextDay($date, $result[$range][$i[$range]]['to']) &amp;&amp; $result[$range][$i[$range]]['price'] == $price)</code> 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. </p>

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

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