title: Sum the same array values into single array
body: <p>I have an array, I want to sum the array values if the array values are the same.</p>
  
  <p>here is the array, In this array, "CustnameGrp" and "BrNamegrp" values are the same, the array "stockcheck" value should be the sum for ex 18, please see my excepted output results, if more  details I will explain </p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [index] =&gt; 0
              [CustidGrp] =&gt; 22
              [CustnameGrp] =&gt; A &amp; H TIRES AND BRAKES
              [TransTypeGrp] =&gt; 1
              [total] =&gt; 0
              [stockcheck] =&gt; 9
              [orders] =&gt; 0
              [NumLines] =&gt; 0
              [AcctidGrp] =&gt; 29
              [banchidgrp] =&gt; 26
              [prvidergrp] =&gt; NEXLINKSHOPWARE
              [prviderNamegrp] =&gt; Shop Ware
              [BrNamegrp] =&gt; Valencia
              [UserNamegrp] =&gt; shopware
              [UserTypeDescgrp] =&gt; SMS
              [UserTypeIdgrp] =&gt; 6
          )
  
      [1] =&gt; Array
          (
              [index] =&gt; 1
              [CustidGrp] =&gt; 22
              [CustnameGrp] =&gt; A &amp; H TIRES AND BRAKES
              [TransTypeGrp] =&gt; 1
              [total] =&gt; 0
              [stockcheck] =&gt; 9
              [orders] =&gt; 0
              [NumLines] =&gt; 0
              [AcctidGrp] =&gt; 29
              [banchidgrp] =&gt; 26
              [prvidergrp] =&gt; ALLDATACL
              [prviderNamegrp] =&gt; ALL Data
              [BrNamegrp] =&gt; Valencia
              [UserNamegrp] =&gt; npmam
              [UserTypeDescgrp] =&gt; SMS
              [UserTypeIdgrp] =&gt; 6
          )
  )
  </code></pre>
  
  <p>I am excepting the output as follows</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [index] =&gt; 0
              [CustidGrp] =&gt; 22
              [CustnameGrp] =&gt; A &amp; H TIRES AND BRAKES
              [TransTypeGrp] =&gt; 1
              [total] =&gt; 0
              [stockcheck] =&gt; 18
              [orders] =&gt; 0
              [NumLines] =&gt; 0
              [AcctidGrp] =&gt; 29
              [banchidgrp] =&gt; 26
              [prvidergrp] =&gt; NEXLINKSHOPWARE
              [prviderNamegrp] =&gt; Shop Ware
              [BrNamegrp] =&gt; Valencia
              [UserNamegrp] =&gt; shopware
              [UserTypeDescgrp] =&gt; SMS
              [UserTypeIdgrp] =&gt; 6
          )
  )
  </code></pre>
  
  <p>I have tried like this as follows.</p>
  
  <pre><code>$sumArray = array();
  foreach ($disArr as $k=&gt;$subArray) {
    foreach ($subArray as $id=&gt;$value) {
       echo $value;
        if (array_key_exists($value, $sumArray)) {
               $sumArray[$id]['stockcheck']+=$value;
        } else {
            $sumArray[$id]=$value;
        }
  
    }
  }
  </code></pre>