I have a bunch a values I would like to add together which are entered into a form. Right now, the form has 11 lines but it could get larger in the future. I can easily add
You can use an array to store your data, and just loop over it.
$tempTotal = 0;
$balances[] = 5;
$balances[] = 5;
$balances[] = 5;
for ($i = 0; $i <= count($balances); $i++) {
$tempTotal = $tempTotal + $balances[$i];
}
Or for brevity, use a foreach loop:
foreach($balances as $balance) {
$tempTotal += $balance;
}