title: Group rows of data by the leading characters of a column value
body: <p>I have an array as shown below, what I wanted to do is create multiple subarrays based on the date substring of the <code>timestamp</code> column like (<code>2011-02-04</code>):</p>
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [avgvalue] =&gt; 0
              [maxvalue] =&gt; 0
              [minvalue] =&gt; 0
              [nrsamples] =&gt; 0
              [stddeviation] =&gt; 0
              [timestamp] =&gt; 2011-02-04T11:00:00.000Z
          )
  
      [1] =&gt; Array
          (
              [avgvalue] =&gt; 268.3
              [maxvalue] =&gt; 268.3
              [minvalue] =&gt; 268.3
              [nrsamples] =&gt; 0
              [stddeviation] =&gt; 0
              [timestamp] =&gt; 2011-02-04T12:00:00.000Z
          )
  
      [2] =&gt; Array
          (
              [avgvalue] =&gt; 268.391666667
              [maxvalue] =&gt; 268.4
              [minvalue] =&gt; 268.3
              [nrsamples] =&gt; 0.0288675134595
              [stddeviation] =&gt; 0.0288675134595
              [timestamp] =&gt; 2011-02-04T13:00:00.000Z
          )
  
      [3] =&gt; Array
          (
              [avgvalue] =&gt; 268.433333333
              [maxvalue] =&gt; 268.5
              [minvalue] =&gt; 268.4
              [nrsamples] =&gt; 0.0492365963918
              [stddeviation] =&gt; 0.0492365963918
              [timestamp] =&gt; 2011-02-04T14:00:00.000Z
          )
  
      [4] =&gt; Array
          (
              [avgvalue] =&gt; 268.5
              [maxvalue] =&gt; 268.5
              [minvalue] =&gt; 268.5
              [nrsamples] =&gt; 0
              [stddeviation] =&gt; 0
              [timestamp] =&gt; 2011-02-04T15:00:00.000Z
          )
  
      [5] =&gt; Array
          (
              [avgvalue] =&gt; 268.575
              [maxvalue] =&gt; 268.6
              [minvalue] =&gt; 268.5
              [nrsamples] =&gt; 0.0452267016867
              [stddeviation] =&gt; 0.0452267016867
              [timestamp] =&gt; 2011-02-04T16:00:00.000Z
          )
  
      [6] =&gt; Array
          (
              [avgvalue] =&gt; 268.616666667
              [maxvalue] =&gt; 268.7
              [minvalue] =&gt; 268.6
              [nrsamples] =&gt; 0.0389249472081
              [stddeviation] =&gt; 0.0389249472081
              [timestamp] =&gt; 2011-02-04T17:00:00.000Z
          )
  
      [7] =&gt; Array
          (
              [avgvalue] =&gt; 268.7
              [maxvalue] =&gt; 268.7
              [minvalue] =&gt; 268.7
              [nrsamples] =&gt; 0
              [stddeviation] =&gt; 0
              [timestamp] =&gt; 2011-02-04T18:00:00.000Z
          )
  
      [8] =&gt; Array
          (
              [avgvalue] =&gt; 268.741666667
              [maxvalue] =&gt; 268.8
              [minvalue] =&gt; 268.7
              [nrsamples] =&gt; 0.0514928650545
              [stddeviation] =&gt; 0.0514928650545
              [timestamp] =&gt; 2011-02-04T19:00:00.000Z
          )
  
      [9] =&gt; Array
          (
              [avgvalue] =&gt; 268.8
              [maxvalue] =&gt; 268.8
              [minvalue] =&gt; 268.8
              [nrsamples] =&gt; 0
              [stddeviation] =&gt; 0
              [timestamp] =&gt; 2011-02-04T20:00:00.000Z
          )
  
      [10] =&gt; Array
          (
              [avgvalue] =&gt; 268.883333333
              [maxvalue] =&gt; 268.9
              [minvalue] =&gt; 268.8
              [nrsamples] =&gt; 0.0389249472081
              [stddeviation] =&gt; 0.0389249472081
              [timestamp] =&gt; 2011-02-04T21:00:00.000Z
          )
   )
  </code></pre>
  <p>The above array has a timestamp key in each subarray. I exploded the timestamp value to separate the date from the time, now I am having trouble splitting the array into sub-arrays.</p>
  <p>What I wanted was to have one array for <code>2011-02-04</code> (containing all the values for that date) and another array for <code>2011-02-05</code> (containing values for all that date). This can be dynamic, I mean the dates can be even more. So, how can I do that?</p>
  <p>I want it as:</p>
  <pre><code>array[0] =&gt; array(... list of all the values for 2011-02-04),
  array[1] =&gt; array(...list of all values for 2011-02-05)
  </code></pre>