title: algorithm for extracting high and low values from range of db recs
body: <p>I have a data structure like this:</p>
  
  <pre><code> array (size=10)
     1 =&gt; 
      array (size=2)
       'fdate' =&gt; string '11/05/12' (length=8)
       'ftime' =&gt; string '11:13' (length=5)
     2 =&gt; 
      array (size=2)
      'fdate' =&gt; string '11/05/12' (length=8)
      'ftime' =&gt; string '11:13' (length=5)
     3 =&gt; 
      array (size=2)
       'fdate' =&gt; string '11/05/12' (length=8)
       'ftime' =&gt; string '11:50' (length=5)
    4 =&gt; 
      array (size=2)
       'fdate' =&gt; string '11/05/12' (length=8)
       'ftime' =&gt; string '11:51' (length=5)
    5 =&gt; 
      array (size=2)
       'fdate' =&gt; string '11/07/12' (length=8)
       'ftime' =&gt; string '09:11' (length=5)
    6 =&gt; 
      array (size=2)
       'fdate' =&gt; string '11/07/12' (length=8)
       'ftime' =&gt; string '09:12' (length=5)
    7 =&gt; 
      array (size=2)
       'fdate' =&gt; string '11/07/12' (length=8)
       'ftime' =&gt; string '10:29' (length=5)
    8 =&gt; 
      array (size=2)
       'fdate' =&gt; string '11/08/12' (length=8)
       'ftime' =&gt; string '11:06' (length=5)
    9 =&gt; 
      array (size=2)
      'fdate' =&gt; string '11/08/12' (length=8)
      'ftime' =&gt; string '11:06' (length=5)
    10 =&gt; 
      array (size=2)
      'fdate' =&gt; string '11/08/12' (length=8)
      'ftime' =&gt; string '11:07' (length=5)
  </code></pre>
  
  <p>I need to evaluate and end up with the first and last ftime values for each date, in this case </p>
  
  <pre><code> fdate     ftime1 ftime2
   11/05/12, 11:13, 11:51
   11/07/12, 09:11, 10:29
   11/08/12, 11:06, 11:07
  </code></pre>
  
  <p>I have a loop like this:</p>
  
  <pre><code> $struct = array();
   $i = 1;
   foreach($recs as $row){            
     $struct[$i]['fdate'] = $row-&gt;fdate;// store fdate
     $struct[$i]['ftime1'] = $row-&gt;ftime;// store initial ftime
     $currentfdate = $row-&gt;fdate; // use $currentfdate in comparison to $row-&gt;fdate
  
     if($currentfdate &lt;&gt; $row-&gt;fdate){
        $struct[$i]['ftime2'] = $row-&gt;ftime;// store last ftime
     }
  
     $i++;
   }
  </code></pre>
  
  <p>I am not sure how to determine when the fdate changes to trigger the storing of ftime2.</p>