title: How can I group by a count of a subvalue of an array?
body: <p>I've been trying every combination of <code>array_count_values</code> and <code>array_map</code> I can think of.  I'm hoping you can show me the way.</p>
  
  <p>Here's a sample array:</p>
  
  <pre><code>$arr = array(
              array('name' =&gt; 'foo','score' =&gt; 1),
              array('name' =&gt; 'foo','score' =&gt; 2),
              array('name' =&gt; 'bar','score' =&gt; 1)
          );
  </code></pre>
  
  <p>I'd like to combine the scores of all sub values with the same name.  Something like <code>GROUP BY name</code> in MySQL.</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [name] =&gt; foo
              [score] =&gt; 3
          )
  
      [1] =&gt; Array
          (
              [name] =&gt; bar
              [score] =&gt; 1
          )
  )
  </code></pre>
  
  <p>I know there are other questions that sort multidimensional arrays, but I'm not able to find one that sums one of the sub values along the way.</p>