I have two php arrays like these:
Array
(
[0] => Array
(
[id] => 712
[count] => 5
)
[1] => Array
(
[id] => 5510
[count] => 3
)
)
Array
(
[0] => Array
(
[id] => 856
[count] => 7
)
[1] => Array
(
[id] => 5510
[count] => 10
)
)
Now I want to make the merge result like this:
Array
(
[0] => Array
(
[id] => 712
[count] => 5
)
[1] => Array
(
[id] => 856
[count] => 3
)
[2] => Array
(
[id] => 5510
[count] => 13
)
)
Just add the count up of those having the same id.
And of course the real array is much more complicated than the example above.
Can you show me a way to deal with this?
This should work for you
Usage
Output