Hello,
If I had a for loop like so
if ($_POST['Submit']) { for ($i = 0; $i < count($_POST['amount']); $i++) { echo "<p>{$_POST['amount][$i]}</p><br/>"; } }
How could I keep a tally of all these and output the total when the loop has finished?
you do not need a for nor a foreach loop for this
$_POST['amount'] = array(1,2,3,4,5,6,7,8,9); echo implode('<br>', $_POST['amount']); echo '<br>and the sum is ' . array_sum($_POST['amount']);
Thanks for that.