title: Recursively group arrays on multiple keys
body: <p>I have an array of objects for example: </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [Id] =&gt; 1
              [Name] =&gt; Toy Car
              [Category] =&gt; Toys
              [Price] =&gt; 2.99
              [OnSale] =&gt; false
          )
      ...
  )
  </code></pre>
  
  <p>But I'd like them to be grouped by Category, then by OnSale. </p>
  
  <p>So far I have been able to group by category using: </p>
  
  <pre><code>$result = array();
  foreach ($data as $element) {
      $result[$element['Category']][] = $element;
  }
  </code></pre>
  
  <p>But I am unsure how to nest another foreach or recursively group them once they have been grouped by Category. Any help is appreciated!</p>