I need to do a PHP while loop, but only if the variable is true. And I can't put the while loop in the if statement, which seems obvious since the code block is huge and it would be ugly and confusing. Do I need to break the code in a loop into a function, or is there an easier way to handle this?
Here is the basic idea:
if(condition){
while(another_condition){
//huge block of code loops many times
}
} else {
// huge block of code runs once
}
I want a huge block of code to be executed regardless of the state of the condition variable, but only to be executed once if the condition is false and executed as long as another_condition is true if the condition is true.
The following code does not work, but gives an idea of what I want to accomplish:
if(condition){ while(another_condition){ }
if (condition){ } }
early.
julio source
share