title: PHP array by reference persists
body: <p>I have encountered something strange, an hope someone can explain what's happening. I've boiled it down to the following case for reproducing on PHP Version 5.3.10-1ubuntu3.21:</p>
  
  <pre><code>$lines = array("foo" =&gt; "bar");
  
  foreach ($lines as &amp;$line) { } // Trouble-causer
  
  $temp = $lines;
  
  foreach ($lines as $key =&gt; $line) {
      $lines[$key] = "test";
  }
  print_r($lines);
  print_r($temp);
  </code></pre>
  
  <p>The expected result of this, since I'm not working on <code>$temp</code>, is</p>
  
  <pre><code>Array
  (
      [foo] =&gt; test
  )
  Array
  (
      [foo] =&gt; bar
  )
  </code></pre>
  
  <p>But the actual result is</p>
  
  <pre><code>Array
  (
      [foo] =&gt; test
  )
  Array
  (
      [foo] =&gt; test
  )
  </code></pre>
  
  <p>If I remove the line marked <code>Trouble-causer</code> it works as expected. Somehow the fact that I cycled <code>$lines</code> items by reference persists into the next iteration. Is this to be expected?</p>