co.ador Posted February 10, 2010 Share Posted February 10, 2010 <?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] . " "); } } ?> 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? Link to comment https://forums.phpfreaks.com/topic/191643-modify-a-script-to-add-instead-of-increment/ Share on other sites More sharing options...
co.ador Posted February 10, 2010 Author Share Posted February 10, 2010 I 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); } ?> Link to comment https://forums.phpfreaks.com/topic/191643-modify-a-script-to-add-instead-of-increment/#findComment-1010172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.