title: Sum array integer values and Combine duplicated non integer values
body: <p>I have an array as shown below, I want to get their non integer duplicated values as one value associated to index key and plus the integer values in their next indexes, in a new index. The one are not duplicated just sort them in same array.</p>
  
  <p><strong>Data Array I have</strong></p>
  
  <pre><code>Array
   (
   [0] =&gt; class 1
   [1] =&gt; 10
   [2] =&gt; class 1
   [3] =&gt; 10
   [4] =&gt; class 2
   [5] =&gt; 30
   [6] =&gt; late fine
   [7] =&gt; 50
   [8] =&gt; late fine
   [9] =&gt; 100
   )
  </code></pre>
  
  <p><strong>The way I want</strong></p>
  
  <pre><code>Array
   (
   [0] =&gt; class 1
   [1] =&gt; 20
   [2] =&gt; class 2
   [3] =&gt; 30
   [4] =&gt; late fine
   [5] =&gt; 150
   )
  </code></pre>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>$i=0; $x=0; $rec = array();
  
  while($i &lt; count($data)){       
      while($x &lt; count($data)){           
          if($data[$i] == $data[$x]){         
              $rec[] = $data[$i];             
          }                   
          $x++;
      }
  
      $i++;
  }       
  </code></pre>