03.02.2016, 18:21
Quote:
Thanks for answering people. Appreciated.
I know I have to use it inside a loop. That was just an example. However, can you tell me in which condition continue; is needed? I kinda didn't understand Mencent's answer. Also, do I have to use break; to stop every loop? Even while using foreach. No matter if it's a small code or a large one. |
PHP код:
new var = -1;
while(1) //unlimited loop
{
var++;
if(var == 5) //if var is 5, then the printf and the "if var =10" check will be skipped
{
continue;
}
printf("%d", var);
if(var == 10) //if var is 10, the loop will break
{
break;
}
}