What are the potential pitfalls of manually iterating through arrays to sum up values in PHP?

Manually iterating through arrays to sum up values in PHP can be error-prone and inefficient, as it requires writing custom code to handle the iteration and summing process. To solve this issue, you can use built-in PHP functions like array_sum() to easily calculate the sum of values in an array.

// Example of summing up values in an array using array_sum()
$array = [1, 2, 3, 4, 5];
$sum = array_sum($array);
echo $sum; // Output: 15