CopyPastehas never been so tasty!

Uses of continue statement in php

by anonymous

  • 0
  • 0
  • 0
59 views

Orignal Source:http://codingvilla.com/uses-continue-statement-php-single-article-579.aspx

 

Continue keyword:

 

Continue is a keyword used to skip the current iteration execution and transfer the control to the next iteration. Use of continue statement violate the structural programming rules.

 

Continue statement in PHP:

 

To skip the execution of current iteration and transfer the control to the next iteration we use continue statement. This statement is used within the body of switch, for each, do-while, for iterations. In this code we have displayed values that will display the values of arrays if i is equal to 3 then skip that iteration and transfer control to next.

 

Code:

 

<?php

$stages = array(50, 110, 130, 71, 203);

$count = count($stages);

for ($i=0; $i<$count; $i++) {

if ($i == 3) {

continue;

}

echo 'Stage '.($i+1).' Score: '.$stages[$i].'<br />';

}

?>

 

 

This is simple code that used continue statement to skip the execution of current iteration and transfer the control to next iteration in php.

 

This simple article tellsthat how we can use continue statement in php.

Add A Comment: