Break statement inside two while loops

后端 未结 11 1227
时光取名叫无心
时光取名叫无心 2020-12-24 14:00

Let\'s say I have this:

while(a){

  while(b){

   if(b == 10)
     break;
 }
}

Question: Will the break statement take m

11条回答
  •  情话喂你
    2020-12-24 14:48

    As a curious note, in PHP the break statement accept a numeric parameter which tells how many outer loops you want to break, like this:

    $i = 0;
    while (++$i) {
       switch ($i) {
          case 5:
             echo "At 5
    \n"; break 1; /* Exit only the switch. */ case 10: echo "At 10; quitting
    \n"; break 2; /* Exit the switch and the while. */ default: break; } }

提交回复
热议问题