title: Sort array into assoc array but add consecutive dates on same rate
body: <p>I have the following array of rates.</p>
  
  <pre><code>$rates = array(
      0  =&gt; 200,
      1  =&gt; 150,
      2  =&gt; 150,
      3  =&gt; 220,
      4  =&gt; 300,
      5  =&gt; 310,
      6  =&gt; 350,
      7  =&gt; 325,
      8  =&gt; 325,
      9 =&gt; 325,
      10 =&gt; 300,
  );
  </code></pre>
  
  <p>So it must be formatted by taking todays date as the first date and adding into the assoc array the following start_date, finish_date, rate, if there are two or more consecutive dates then that gets pushed in the same index but the finsih date will end depending how many days the rate was the same here is an example of how it should look.</p>
  
  <pre><code>$new_rates = array (
      'start_date' =&gt; '2018-12-07'
      'finish_date' =&gt; '2018-12-07'
      'rate' =&gt; '200',
      'start_date' =&gt; '2018-12-08'
      'finish_date' =&gt; '2018-12-09'
      'rate' =&gt; '150',
      'start_date' =&gt; '2018-12-10'
      'finish_date' =&gt; '2018-12-10'
      'rate' =&gt; '220',
      'start_date' =&gt; '2018-12-11'
      'finish_date' =&gt; '2018-12-11'
      'rate' =&gt; '300',
      'start_date' =&gt; '2018-12-12'
      'finish_date' =&gt; '2018-12-12'
      'rate' =&gt; '310',
      'start_date' =&gt; '2018-12-13'
      'finish_date' =&gt; '2018-12-13'
      'rate' =&gt; '350',
      'start_date' =&gt; '2018-12-14'
      'finish_date' =&gt; '2018-12-15'
      'rate' =&gt; '325',
      'start_date' =&gt; '2018-12-16'
      'finish_date' =&gt; '2018-12-16'
      'rate' =&gt; '300',
  );
  </code></pre>
  
  <p>As you can see the first start_date can start on todays date etc.
  Any help would be greatly appreciated, thanks.</p>