"difference between break and continue in php?" Answer’s


break ends a loop completely, continue just shortcuts the current iteration and moves on to the next iteration.

while ($foo) {   <--------------------?
    continue;    --- goes back here --?
    break;       ----- jumps here ----?
}                                     |

This would be used like so:

while ($droid = searchDroids()) {
    if ($droid != $theDroidYoureLookingFor) {
        continue; // ..the search with the next droid

    $foundDroidYoureLookingFor = true;
    break; // ..off the search
Wednesday, March 31, 2021
answered 10 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :