Does foreach do its work on a copy of the input array?
<p>I've been studying some test questions. One of the questions about array iteration. Here it is : </p>

<blockquote>
  <p>What is the best way to iterate through the $myarray array, assuming
  you want to modify the value of each element as you do?</p>

<pre><code>&lt;?php
$myarray = array ("My String",
"Another String",
"Hi, Mom!");
?&gt;
</code></pre>
  
  <p>A.    Using a for loop</p>
  
  <p>B.    Using a foreach loop</p>
  
  <p>C.    Using a while loop</p>
  
  <p>D.    Using a do…while loop</p>
  
  <p>E.    There is no way to accomplish this goals</p>
</blockquote>

<p>My answer is "of course foreach loop". But according to the answer sheet :</p>

<blockquote>
  <p>Normally, the foreach statement is the most appropriate construct for
  iterating through an array. However, because we are being asked to
  modify each element in the array, this option is not available, since
  foreach works on a copy of the array and would therefore result in
  added overhead. Although a while loop or a do…while loop might work,
  because the array is sequentially indexed a for statement is best
  suited for the task, making Answer A correct.</p>
</blockquote>

<p>I still think foreach is the best. And as long as I use it with key I can modify values.</p>

<pre><code>&lt;?php
foreach($myarray as $k=&gt;$v){
    $myarray[$k] = "Modified ".$v;
}
?&gt;
</code></pre>

<p>Do I miss something?</p>
