Each 3rd Increment Loop PHP -
hi im looking way breakout of loop every 3 increments echo static string.this script echos "test" after each increment. want test after each 3rd increment. ideas ?
my loop:
<?php $i = 0; while (++$i < 100){ $x = $i - 3; if ($i+3) {echo $i . "<br>test<br>";} else{ echo $i . "<br>";} } ?>
try below code
<?php for($i=1;$i<=100;$i++) { if($i%3==0) { echo $i."test"."<br>"; } } ?>
Comments
Post a Comment