Consider a scenario where you need to execute a block of code for each element in an array. Which control structure is most suitable for this purpose?
- for loop
- if statement
- switch statement
- while loop
A 'for' loop is the most suitable control structure for iterating through each element in an array. It allows you to specify the start and end conditions and easily iterate through array elements.
Loading...
Related Quiz
- Which PHP function can be used to customize the error handler?
- A class that cannot be instantiated and is intended to be inherited by other classes is known as a ________ class.
- An example of a superglobal in PHP is $_POST, which is used to collect form data sent with the ______ method.
- For how long does a session variable persist by default in PHP?
- Which function can be used in PHP to filter and sanitize user input?