<?php
$array=array(
0 => array(
11 => 18.000,
14 => 25.100,
15 => 5.000,
16 => 8.000,
19 => 21.600
),
1 => array(
11 => 9.100,
12 => 2.700,
14 => 2.300,
15 => 18.800,
16 => 9.500,
17 => 6.900,
19 => 9.400
),
2 => array(
14 => 5.700
),
3 => array(
17 => 2.800,
20 => 6.000
),
4 => array(
24 => 5.000,
25 => 6.000,
26 => 2.7
),
5 => array(
16 => 2.200
),
6 => array(
14 => 13.000,
15 => 2.000,
16 => 4.300,
19 => 6.000
),
7 => array(
32 => 5.000,
36 => 18.500
)
);
foreach($array as $subarray){
foreach($subarray as $k=>$v){
if(!isset($result[$k])){
$result[$k]=$v;
}else{
$result[$k]+=$v;
}
}
}
var_export($result);
- Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- array (
11 => 27.1,
14 => 46.1,
15 => 25.8,
16 => 24.0,
19 => 37.0,
12 => 2.7,
17 => 9.7,
20 => 6.0,
24 => 5.0,
25 => 6.0,
26 => 2.7,
32 => 5.0,
36 => 18.5,
)
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
array (
11 => 27.1,
14 => 46.1,
15 => 25.8,
16 => 24.0,
19 => 37.0,
12 => 2.7,
17 => 9.7,
20 => 6.0,
24 => 5.0,
25 => 6.0,
26 => 2.7,
32 => 5.0,
36 => 18.5,
)
preferences:
169.6 ms | 402 KiB | 170 Q