<?php $aDoor = $_POST['formDoor']; if(empty($aDoor)) { echo("You didn't select any buildings."); } else { $N = count($aDoor); echo("You selected $N door(s): "); for($i=0; $i < $N; $i++) { echo($aDoor[$i] . " "); } } ?> PHP: The script above will increment and then echo the extracted values of the variable array $aDoor, How can I modify to sum the values instead?
Found the solution thank you guys. <?php $aDoor = $_POST['formDoor']; if(empty($aDoor)) { echo("You didn't select any buildings."); } else { $N = count($aDoor); echo("You selected $N door(s): "); for($i=0; $i < $N; $i++) { echo($aDoor[$i] . " "); } echo "Sum of vlues = ".array_sum($aDoor); } ?> PHP: