In your PHP script, you have a loop inside another loop. You want to stop the execution of both loops once a certain condition is met. How would you do this using break?

  • Use the break statement inside the inner loop to terminate both the inner loop and the outer loop.
  • Use the continue statement to skip the rest of the inner loop iteration and continue with the next iteration of the outer loop.
  • Use the return statement to exit both loops and return a value.
  • Use the exit statement to stop the script execution.
The correct option is: "Use the break statement inside the inner loop to terminate both the inner loop and the outer loop." By using the break statement inside the inner loop, you can terminate both the inner loop and the outer loop when a certain condition is met. This allows you to break out of multiple nested loops simultaneously. Learn more: https://www.php.net/manual/en/control-structures.break.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *