If you are trying to have your second continue apply to the foreach loop, you will have to change it from
continue;
to
continue 2;
This will instruct PHP to apply the continue statement to the second nested loop, which is the foreach loop. Otherwise, it will only apply to the for loop.