Trying to add up numbers in PHP for loop -


i'm trying add numbers output in code, how can this?

$tall1 = 0;  ($tall1=0; $tall1 <= 100; $tall1++) {      if ($tall1 % 3 == 0) {         echo $tall1 . " ";         $tall++;     } } 

$total = 0; //initialize variable  ($tall1=0; $tall1 <= 100; $tall1++) {      if ($tall1 % 3 == 0) {         echo $tall1 . " ";         $total += $tall1; //add printed number initialized variable. same writing $total = $total + $tall1;     } }  echo "total: ".$total; //do variable, in case, print 

some notes initial code:

$tall1 = 0; //you don't need this, done loop (      $tall1=0; //this $tall1 initialized      $tall1 <= 100;       $tall1++ //this $tall1 incremented every time        ) {      if ($tall1 % 3 == 0) {         echo $tall1 . " ";         $tall++; //this variable not used anywhere. if meant $tall1, don't need this, done loop. if did not mean $tall1, wanted count how many times if statement runs, need initialize variable (place $tall=0; @ top)     } } 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -