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
Loading...
Related Quiz
- A constructor in a PHP class is defined using the __construct() method.
- The $GLOBALS superglobal in PHP is an associative array.
- What are the libxml functions in PHP used for?
- In PHP file upload, the $_FILES array contains keys like 'name', 'type', 'size', 'tmp_name', and 'error' which represent ______.
- You are writing a PHP script and you need to send an email. How would you do this using mail functions?