Are there any potential pitfalls or limitations when using array_sum() for calculating row sums in PHP?

One potential limitation of using array_sum() for calculating row sums in PHP is that it only works for one-dimensional arrays. If you are working with a multidimensional array and want to calculate row sums, you will need to use a loop to iterate over each row and calculate the sum manually.

// Example of calculating row sums in a multidimensional array
$matrix = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
];

$rowSums = [];
foreach ($matrix as $row) {
    $rowSums[] = array_sum($row);
}

print_r($rowSums);