There is most likely no difference. Optimization on this level does usually not make any sense in an interpreted language like PHP.
In most cases, your logic will require you to put the block inside the loop anyway. Otherwise, the loop will continue even if an error has occurred.