Merging same array values in multidimentional array using PHP
<p>I have this multi-dimentional array:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [name] =&gt; lorem
            [id] =&gt; 1
            [type] =&gt; Q1
            [q1] =&gt; 39.55
            [q2] =&gt; 0

        )

    [1] =&gt; Array
        (
            [name] =&gt; lorem
            [id] =&gt; 1
            [type] =&gt; Q2
            [q1] =&gt; 0;
            [q2] =&gt; 39.55
        )

    [2] =&gt; Array
        (
            [name] =&gt; lorem
            [id] =&gt; 1
            [type] =&gt; Q1
            [q1] =&gt; 39.55
            [q2] =&gt; 39.55
        )

    [3] =&gt; Array
        (
            [owner_name] =&gt; name
            [id] =&gt; 2
            [type] =&gt; Q1
            [q1] =&gt; 39.55
        [q2] =&gt; 0
        )

)
</code></pre>

<p>I want to combine all the items in an array with the same id and total all the q1 and q2 in the same owner only in the same type creating a new array structure:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [name] =&gt; lorem
            [id] =&gt; 1
        [Q1_total = &gt; 79.1
            [q2_total] =&gt; 79.1
        )

    [1] =&gt; Array
        (
            [owner_name] =&gt; name
            [id] =&gt; 2
            [type] =&gt; Q1
            [Q1_total] =&gt; 39.55
        [Q2_total] =&gt; 0;
        )

)
</code></pre>
