How to get the sum of these arrays by column?
$arr = [["0","45","0","0","-100","0"],
["22","0","0","12","18","0"],
["0","0","14","12","0","0"]];
expected output
$sum = ["22","45","14","24","-82","0"];
>Solution :
You can use array_sum() and array_column().
$sums = [];
foreach (array_keys($arr[0]) as $column) {
$sums[$column] = array_sum(array_column($arr, $column));
}