PHP/Statement/continue
Содержание
Continue Statement
<source lang="html4strict">
<html>
<head> <title>Continue Statement</title> </head> <body> <?php $i = 0; $passes = ""; while ( $i < 5 ) { $i++; if( $i == 3 ) continue; $passes .= "$i "; } echo("Loop stopped at $i
"); echo("Completed iterations:$passes"); ?> </body>
</html>
</source>
continue within a for loop
<source lang="html4strict">
<?php
$usernames = array("grace","doris","gary","nate","missing","tom"); for ($x=0; $x < count($usernames); $x++) { if ($usernames[$x] == "missing") continue; echo "Staff member: $usernames[$x]
"; }
?>
</source>
Using continue instead of break
<source lang="html4strict">
<?php $counter=-3; for (;$counter<10;$counter++){
if ($counter==0){ echo "Skipping to avoid division by zero.
"; continue; } echo "100/$counter ",100/$counter,"
";
} ?>
</source>
Using the continue Statement
<source lang="html4strict">
<html> <head><title>Using the continue Statement</title></head> <body>
<?php
$counter = -4; for ( ; $counter <= 10; $counter++ ) { if ( $counter == 0 ) { continue; } $temp = 4000/$counter; print "4000 divided by $counter is .. $temp
"; }
?>
</body> </html>
</source>