Multiple choice php

What is the best way to iterate through the \$myarray array, assuming you want to modify the value of each element as you do?

\$myarray = array ("My String","Another String","Hi, Mom!");

  1. Using a for loop

  2. Using a foreach loop

  3. Using a while loop

  4. Using a do..while loop

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To modify array elements during iteration in older PHP versions, a 'for' loop using the index is safest. While 'foreach' can use references (&$value) in newer PHP, the 'for' loop directly accesses the original array index, ensuring the modification persists without reference-related side effects.