In regular loop, for, foreach, while block, you can simply use next for next loop, or last to exit the loop, however, this is not true for do while 'loop'
here is one example:

do {
...
...
...
if () {
last;
}
} while (EXPR);

In the example above, you will see that  the 'last' doesn't work.

Here is how, in do BLOCK while (EXPR), do is not really a loop structure. So, last, next, and redo are not supposed to be used there. Get rid of the last and adjust the EXPR to evaluate false when that situation is found.

Also, turn on strict, which should give you at least a warning here.

Alternative ways to exit from do while loop

Mover while condition to the begging

Turn do while to while loop

while ( EXPR ) {
...
...
  if (something) {
    last;
  }
}

Turn do to a block

If you really need do while for your work, then here is another solution

{
    do {
        ...
        if (...)
        {
            ...
            last;
        }
    } while (...);
}

Or this way

do {{
    ...
    if (...)
    {
        ...
        next;
    }
    ...
}} while (...);


Have fun!