$payments = array(100, 200, 300); $total = 0; foreach ($payments as $payment) { $total += $payment; } return $total;