How to use the continue statement, to skip the rest of the current loop iteration in PHP

2 Answers

0 votes
$i = 0;
while ($i++ < 10) 
{
    if (!($i % 2)) 
        continue;
    
    echo $i . "<br />";
}


/*
run: 

1
3
5
7
9 

*/

 



answered Jun 5, 2016 by avibootz
0 votes
for ($i = 0; $i < 10; $i++)
{
    if (!($i % 2)) 
        continue;
    
    echo $i . "<br />";
}


/*
run: 

1
3
5
7
9 

*/

 



answered Jun 5, 2016 by avibootz
...