3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $i = 1; // "$i" is a simple variable that will represent our loop's iteration number while ($i <= 8) { // forces the while loop to have an iteration ceiling of 8 and no more echo 'I am index ' . $i . ' of this while loop. <br />'; $i++; // increment value by one each time the loop iterates } ?>
Output for 4.3.0 - 7.2.0
I am index 1 of this while loop. <br />I am index 2 of this while loop. <br />I am index 3 of this while loop. <br />I am index 4 of this while loop. <br />I am index 5 of this while loop. <br />I am index 6 of this while loop. <br />I am index 7 of this while loop. <br />I am index 8 of this while loop. <br />