Note that there are some explanatory texts on larger screens.

plurals
  1. POSum of 2 array elements with the same keys
    primarykey
    data
    text
    <p>Hi I have 2 arrays like</p> <pre><code> array(a) { [0]=&gt; array(2) { ["count"]=&gt; string(2) "22" ["hour"]=&gt; string(1) "0" } [1]=&gt; array(2) { ["count"]=&gt; string(2) "17" ["hour"]=&gt; string(1) "1" } [2]=&gt; array(2) { ["count"]=&gt; string(2) "22" ["hour"]=&gt; string(1) "2" } [3]=&gt; array(2) { ["count"]=&gt; string(2) "15" ["hour"]=&gt; string(1) "3" } [4]=&gt; array(2) { ["count"]=&gt; string(2) "15" ["hour"]=&gt; string(1) "4" } } </code></pre> <p>And I have the second array with different (count) values </p> <pre><code> array(b) { [0]=&gt; array(2) { ["count"]=&gt; string(2) "12" ["hour"]=&gt; string(1) "0" } [1]=&gt; array(2) { ["count"]=&gt; string(2) "36" ["hour"]=&gt; string(1) "1" } [2]=&gt; array(2) { ["count"]=&gt; string(2) "59" ["hour"]=&gt; string(1) "2" } [3]=&gt; array(2) { ["count"]=&gt; string(2) "5" ["hour"]=&gt; string(1) "3" } [4]=&gt; array(2) { ["count"]=&gt; string(2) "27" ["hour"]=&gt; string(1) "4" } } </code></pre> <p>Can you please tell me how can I get the sum of ["count"]s of both arrays and get a new array like </p> <pre><code> array(c) { [0]=&gt; array(2) { ["count"]=&gt; string(2) "34" ["hour"]=&gt; string(1) "0" } [1]=&gt; array(2) { ["count"]=&gt; string(2) "53" ["hour"]=&gt; string(1) "1" } [2]=&gt; array(2) { ["count"]=&gt; string(2) "81" ["hour"]=&gt; string(1) "2" } [3]=&gt; array(2) { ["count"]=&gt; string(2) "20" ["hour"]=&gt; string(1) "3" } [4]=&gt; array(2) { ["count"]=&gt; string(2) "42" ["hour"]=&gt; string(1) "4" } } </code></pre> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload