title: Getting an undefined offset in my PHP array while in a foreach
body: <p>I need some help, even though I think I'm checking for the length of the array and I should be breaking out of the loop, I still get warnings on my [else if ($value....] line. So either I'm missing something crucial or I've been staring at this code segment too long and its obvious.  Any insight would be appreciated.</p>
  
  <pre><code>    $count = count($filter); //Filter is an array
      if ($count &gt; 1 ){
          //Compare values and generate a range to choose from
          $i = 1;
          foreach($filter as $value){
              //Break the loop if at the end of the array
              if ($i &gt;= $count){
                  //throw new exception($i .' '.$count);
                  break;
              }
              //if the value is smaller then the next procceding value, because they are already in order of presidence,
              //add it to our range of potentials.
              else if($value &lt; $filter[$i]-&gt;value){
                  array_push($range, key($filter));
              }
          $i++;
          }           
      }else {
          return false;
      }
  </code></pre>