Using the new array_column() function of PHP 5.5:
$colCount = count($arr[0]);
$result = array();
for ($i = 0; $i < $colCount; $i++) {
$result[] =
array_sum(
array_column($arr, $i)
);
}
var_dump($result);
or for earlier versions of PHP
$result = array();
foreach(call_user_func_array('array_map',array_merge(array(NULL),$arr)) as $column) {
$result[] = array_sum($column);
}
var_dump($result);
Both methods assume the same number of entries in each sub-array
EDIT
Filtering out the non numeric values to return an empty string for the first column:
$colCount = count($arr[0]);
$result = array();
for ($i = 0; $i < $colCount; $i++) {
$values = array_filter(
array_column($arr, $i),
'is_numeric'
);
$result[] = count($values) > 0 ? array_sum($values) : '';
}
var_dump($result);
and
$result = array();
foreach(call_user_func_array('array_map',array_merge(array(NULL),$arr)) as $column) {
$values = array_filter($column,
'is_numeric'
);
$result[] = count($values) > 0 ? array_sum($values) : '';
}
var_dump($result);
If you want a null instead, then simply replace the '' with null