title: PHP split array based on search results
body: <p>I have a multidimensional array which is created by a MySQL query which collects results based on a number of groups and sums. The array is below. </p>
  
  <p>I'm interested in the costtotal and hitcount for each type of 'ad_type', 'click_status' and 'link_status' variation.</p>
  
  <p>The possible values of the 3 types of variable are known:
  i.e. </p>
  
  <ul>
  <li>ad_type 0 / 1</li>
  <li>click_status 2 / 3</li>
  <li>link_status 1 / 2</li>
  </ul>
  
  <p>I would like to create a new array based on the results of each combination. </p>
  
  <p>I'm guessing a search or split would do it but I'm not having much luck. </p>
  
  <p>How would I go about doing this?</p>
  
  <pre><code>Array
  (
      [0.261346210037681] =&gt; Array
          (
              [costtotal] =&gt; 0.0015
              [hitcount] =&gt; 1
              [ad_type] =&gt; 0
              [click_status] =&gt; 2
              [link_status] =&gt; 1
          )
  
      [0.190427019438173] =&gt; Array
          (
              [costtotal] =&gt; 0.001
              [hitcount] =&gt; 1
              [ad_type] =&gt; 0
              [click_status] =&gt; 3
              [link_status] =&gt; 1
          )
  
      [0.563596305962276] =&gt; Array
          (
              [costtotal] =&gt; 0.007
              [hitcount] =&gt; 5
              [ad_type] =&gt; 1
              [click_status] =&gt; 2
              [link_status] =&gt; 1
          )
  
      [0.893211513658251] =&gt; Array
          (
              [costtotal] =&gt; 0
              [hitcount] =&gt; 3
              [ad_type] =&gt; 1
              [click_status] =&gt; 2
              [link_status] =&gt; 2
          )
  
      [0.209184847035617] =&gt; Array
          (
              [costtotal] =&gt; 0.004
              [hitcount] =&gt; 2
              [ad_type] =&gt; 1
              [click_status] =&gt; 3
              [link_status] =&gt; 1
          )
  
      [0.73545002260753] =&gt; Array
          (
              [costtotal] =&gt; 0
              [hitcount] =&gt; 1
              [ad_type] =&gt; 1
              [click_status] =&gt; 3
              [link_status] =&gt; 2
          )
  
  )
  </code></pre>