I have a function containing a while loop and other code. I am trying to break out of the while loop and ignore the rest of the code in the same funtion when the condition doesn't meet but it executes no matter if the condition matches or not. Does anyone have any solution to this?
Thanks
if (...whatever....) {break;}
I did this but it broke out of the loop not the function. I want it break out of the loop and the function, which contains the loop. Any suggestion?
Well... after the loop, use an if... function my_function() { $exit_funtion = false; while(condition) { lalalala... if(condition) { $exit_function = true; break; } } if(!$exit_function) { code ... } }
why not just do 'return;' where you want to break, that will end the end the funtion and return a null value