I have two arrays that look like this:
$r1[$db_rate_type] = Array($db_rate_in, $db_rate_out, $db_rate_desc);
$r2[$db_rate_type] = Array($db_rate_in, $db_rate_out, $db_rate_desc);
Lets say the value of each array looks like this:
Array 1:
[1] = [1400] [20] ["Standard timelønn"]
[2] = [NULL] [20] ["Kveldstillegg"]
Array 2:
[1] = [NULL] [20] ["Standard timelønn"]
[2] = [1500] [20] ["Kveldstillegg"]
How can I sum the value of the array, but keep the counting IDs at the beginning?
I have tried the following code:
$c = array_map(function () {
return array_sum(func_get_args());
}, $a, $b);
But it counts only for one array added to another array, and not arrays WITHIN arrays. What I prefer to have returned is the following:
Array returned:
[1] = [1400] [40] ["Standard timelønn"]
[2] = [1500] [40] ["Kveldstillegg"]
So how can I do this, but have it as effective as possible?
Full code of the database fetch etc. can be found here