title: Combine two arrays but add Values of duplicate keys together
body: <p>I have two arrays, $ids and $quants (ids and quantities of stock items) that need to be combined, but instead of replacing or removing duplicates, their values should be added together. </p>
  
  <p>Currently I'm using array_combine() but this means that some of the quantities are lost where multiple of the same id exists.</p>
  
  <p>e.g. </p>
  
  <pre><code>$ids = Array(1, 1, 2, 3);
  $quants = Array(10, 20, 30, 40);
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>$combined = Array(
  [1] =&gt; 30
  [2] =&gt; 30
  [3] =&gt; 40
  )
  </code></pre>
  
  <p>Thanks in advance for any advice</p>