title: Create a grouped array from another list of array items
body: <p>I have an array of apps with ids and categories like this:</p>
  
  <pre><code>[apps] =&gt; Array
              (
                  [0] =&gt; stdClass Object
                      (
                          [id] =&gt; 0
                          [categoryid] =&gt; 0
                      )
  
                  [1] =&gt; stdClass Object
                      (
                          [id] =&gt; 31265
                          [categoryid] =&gt; 12
                      )
  
                  [2] =&gt; stdClass Object
                      (
                          [id] =&gt; 15965
                          [categoryid] =&gt; 2
                      )
  
                  [3] =&gt; stdClass Object
                      (
                          [id] =&gt; 16554
                          [categoryid] =&gt; 12
                      )
  )
  </code></pre>
  
  <p>I am trying to get all apps for a category based on this request. So, the resultant output for:</p>
  
  <pre><code>For CategoryId 12:
  ----------------
  [apps] =&gt; Array
              (
                  [0] =&gt; 31265
                  [1] =&gt; 16554
              )
  
  For CategoryId 2:
  ----------------
  [apps] =&gt; Array
              (
                  [0] =&gt; 15965
              )
  
  For CategoryId 0:
  ----------------
  [apps] =&gt; Array
              (
                  [0] =&gt; 0
              )
  </code></pre>
  
  <p>I believe i need to use nested foreach loops, but is there an efficient method?</p>
  
  <p>Thanks</p>