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.
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
}
You can use continue
control
structure
for skip an iteration
. Please read the docs
while($a = getrow()){
if($a == 'something'){
continue; // skip iteration
}
//rest code which you want to run
}