Which of the following are common uses of foreach loops in PHP?

  • Iterating over an array and performing operations on each element
  • Iterating over a numeric range of values and performing operations
  • Executing a block of code a specific number of times
  • There are no common uses of foreach loops in PHP
The correct option is: "Iterating over an array and performing operations on each element." A common use of the foreach loop in PHP is to iterate over an array and perform operations on each element individually. This allows you to process each element without explicitly managing the iteration counter. The foreach loop simplifies the process of working with arrays in PHP. Learn more: https://www.php.net/manual/en/control-structures.foreach.php
Add your answer
Loading...

Leave a comment

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