Home > Backend Development > PHP Tutorial > Analysis of the difference between break and continue process control instructions in PHP_PHP Tutorial

Analysis of the difference between break and continue process control instructions in PHP_PHP Tutorial

WBOY
Release: 2016-07-21 15:30:47
Original
1068 people have browsed it

The following example illustrates that
break is used to break out of the currently executing loop and no longer continue to execute the loop.

Copy code The code is as follows:

$i = 0;
while ($i < 7) {
if ($arr[$i] == "stop") {
break;
}
$i++;
}
? >

continue immediately stops the current execution loop and returns to the conditional judgment of the loop to continue the next loop.
Copy code The code is as follows:

while (list($key,$ value) = each($arr)) {
if ($key == "zhoz"){ // If the value of the queried object is equal to zhoz, this record will not be displayed.
continue;
}
do_something ($value);
}
// Example 2
foreach ($list as $temp) {
if ($temp-> ;value == "zhoz") {
continue; // If the value of the queried object is equal to zhoz, this record will not be displayed.
}
do_list; // The records in the array are displayed here
}
?>

Note: the goto loop instruction cannot be used in PHP.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323129.htmlTechArticleThe following example shows that break is used to jump out of the currently executing loop and no longer continue to execute the loop. Copy the code The code is as follows: ?php $i = 0; while ($i 7) { if ($arr[$i] == "stop") { break...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template