PHP Continue
Posted on: March 26, 2010 at 12:00 AM
Advertisement
In this tutorial we will study about continue statement, continue statement is just reverse of the break statement.Examples in this tutorial will make it more clear.

Continue Control Structure:

Continue is another type of control structure which is used to re-initialize the iteration without finishing the current iteration, continue is used within looping structures (like for, foreach, while, do-while and switch case)to avoid rest of the code. 

If we want to continue the higher levels of enclosing loops then we need to use continue with optional numeric argument.

Example:

<?php

$arr=array(1,2,3,4,5);

foreach($arr as $val):

if($val==4)continue;

echo $val."<br/>";

endforeach;

?>

Output:

1
2
3
5

Example:

<?php

$arr=array(1,2,3,4,5,56,76);

for($key=0;$key<7;$key++){

if(!($key%2))

continue;

else

echo $arr[$key]."<br/>";

}

Output:
2
4
56

Advertisement

Related Tags for PHP Continue:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 26, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com