Sum array values of a column within each column of an array with 3 levels
PHP Snippet 1:
foreach($array as $key => $point){
$arr[] = array_sum(array_column( array_column($array,$key),'value'));
}
print_r($arr);
PHP Snippet 2:
<?php
$arr = [];
foreach($array as $point){
foreach($point as $k => $v){
$arr[$k] = ($arr[$k] ?? 0) + $v['value'];
}
}
print_r($arr);
PHP Snippet 3:
var_export(
array_map(
fn(...$col) => array_sum(array_column($col, 'value')),
...$array
)
);
PHP Snippet 4:
array (
0 => 3600,
1 => 7000,
2 => 6000,
)