I need a function that can add the elements of x arrays that have matching elements.
Here is an example of a source array with two elements.
Array
(
[0] => Array
(
[0] => Array
([kwh] => 313.9799,[time_read] => 1311825600)
[1] => Array
([kwh] => 312.3098,[time_read] => 1311826500)
[2] => Array
([kwh] => 302.0525,[time_read] => 1311827400)
[3] => Array
([kwh] => 312.2946,[time_read] => 1311828300)
)
[1] => Array
(
[0] => Array
([kwh] => 723.4205,[time_read] => 1311825600)
[1] => Array
([kwh] => 686.9258,[time_read] => 1311826500)
[2] => Array
([kwh] => 714.3203,[time_read] => 1311827400)
[3] => Array
([kwh] => 707.8232,[time_read] => 1311828300)
)
)
And I'd like to see output like the following. What throws me is that the indexes of the arrays might not match up. One array might have 10 elements while the other might have 20. The time_read value has to be used to find matching array elements.
Array
(
[0] => Array
([kwh] => 1036,[time_read] => 1311825600)
[1] => Array
([kwh] => 998,[time_read] => 1311826500)
[2] => Array
([kwh] => 1016,[time_read] => 1311827400)
[3] => Array
([kwh] => 1019,[time_read] => 1311828300)
)