I am trying to write a code that is capturing number 3. using while loop as the condition, so that the for statement will be the evaluation condition of $x, of the while loop statement, and by the same time, using if statement to evaluate the value of $x=3 and so it can echo ‘three..’; . please enlighten me. thank you
JavaScript
x
<?php
$x = 0;
$y = 5;
while ($x <= $y) {
for ($z = 0; $z < 3; $z++) {
if ($x = 3) {
echo 'three..' . "n";
}
}
$y++;
}
Advertisement
Answer
In while loop, you should increment x variable. If you increment y variable, it will always “true”. So it will be endless loop.
JavaScript
<?php
$x = 0;
$y = 5;
while ($x <= $y) {
// code
$x++;
}