0
For some reason I’m stuck on this
For some reason I’m stuck on this can I have some help plz?? https://www.sololearn.com/learn/PHP/1831/
2 ответов
+ 4
if the keyword continue is reached in a loop, the execution of the code jumps from there, skipping the remaining code in the loop, to the loops condition (in the case of a for loop it jumps to the increment section then the condition as normal).
$x = 0;
while($x < 3) {
$x++;
if($x == 2) {
continue;
}
echo $x."\r\n";
}
Outputs
1
3
When $x has the value of 2 the if statement runs and the loop continues by jumping back to the top of the loop skipping the echo statement and checking the condition agian to continue the loop.
+ 1
thx