What are the potential pitfalls of using array_reduce function in PHP for summing values in an array?

One potential pitfall of using the array_reduce function in PHP for summing values in an array is that it can be less readable and more complex compared to using a simple foreach loop. Additionally, if the initial value passed to array_reduce is not set correctly, it can lead to unexpected results or errors. To avoid these pitfalls, it is recommended to use a foreach loop for simple operations like summing values in an array.

// Using foreach loop to sum values in an array
$numbers = [1, 2, 3, 4, 5];
$sum = 0;

foreach ($numbers as $number) {
    $sum += $number;
}

echo $sum; // Output: 15