title: PHP Sum the values of duplicate keys in ONE array
body: <p>i could not find an exactly similar question so here it is</p>
  
  <p>Given an array...</p>
  
  <pre><code>print_r( $givenArray );
  </code></pre>
  
  <p>Will output this:</p>
  
  <pre><code>array (
      [A] =&gt; 1
      [B] =&gt; 0
      [A] =&gt; 3
      [C] =&gt; 4
  );
  </code></pre>
  
  <p>I need to sum values of the same keys, so the result will look like this</p>
  
  <pre><code>array(
      [A] =&gt; 4
      [B] =&gt; 0
      [C] =&gt; 4
  );
  </code></pre>
  
  <p>How is that possible? thanks</p>
  
  <p><strong>UPD (after the ozthgreat's comment) :</strong></p>
  
  <pre><code>[0] =&gt; array( 
      [name] =&gt; array( 
          [0] =&gt; "A", 
          [1] =&gt; "B",
          [2] =&gt; "C" ) 
      [count] =&gt; array( 
          [0] =&gt; 1, 
          [1] =&gt; 0, 
          [2] =&gt; 4 ) ),
  [1] =&gt; array( 
      [name] =&gt; array(
          [0] =&gt; "A", 
          [1] =&gt; "C") 
      [count] =&gt; array(
          [0] =&gt; 3, 
          [1] =&gt; 4))
  </code></pre>
  
  <p>the 'original' array looks like this...They array before update looks stupid because i tried <code>array_count_values</code> and <code>array_combine</code> and came to that look</p>