duanhe6718 2016-06-07 11:11
浏览 171
已采纳

继续while循环,不包括循环内的continue语句

I have a part in my code:

while($a = getrow()){
//code
}

getrow() is a function which keeps on returning array based on some condition.

what getrow() should return so that the while loop doesn't execute the code inside but takes the next value returned by getrow() function.

  • 写回答

2条回答 默认 最新

  • douchun9719 2016-06-07 11:20
    关注

    While loops will run as long as the condition remains true. So as long as you return rows, the code inside will get executed. If you return false, the while loop will terminate. If you want to conditionally avoid running code within the loop, your option is to return something like 'SKIP' and then inside the while loop check if $a == 'SKIP' and then issue a continue.

    while($a = getrow()){
        if($a == 'SKIP')
            continue;
        //code
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题