Php 在for循环中使用条件运算

Php 在for循环中使用条件运算,php,if-statement,conditional-statements,logical-operators,Php,If Statement,Conditional Statements,Logical Operators,如果条件为真,我需要跳过代码的某些部分,如何在php中实现它 if ($a==0 && $b==0) { //skip this part of the code and exit loop } 您可以使用退出循环 例如: <?php $arr = array('one', 'two', 'three', 'four', 'stop', 'five'); while (list(, $val) = each($arr)) { i

如果条件为真,我需要跳过代码的某些部分,如何在php中实现它

   if ($a==0 && $b==0)
     {

//skip this part of the code and exit loop 
        }
您可以使用退出循环

例如:

<?php
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
while (list(, $val) = each($arr)) {
    if ($val == 'stop') {
        break;    /* You could also write 'break 1;' here. */
    }
    echo "$val<br />\n";
}

你需要养成帮助你解决问题的习惯。您将获得积分,并鼓励其他人帮助您。