title: Why can't I unset a variable in a `foreach` loop?
body: <p>Why can't I unset a variable in a <code>foreach</code> loop?</p>
  
  <pre><code>&lt;?php
  
  $array = array(a,s,d,f,g,h,j,k,l);
  
  foreach($array as $i =&gt; $a){
   unset($array[1]);
   echo $a . "\n";
  }
  
  print_r($array);
  </code></pre>
  
  <p>In <a href="http://codepad.org/rCeNevz5" rel="nofollow">the code</a>, the variable is in scope within the <code>foreach</code> loop, but outside the loop it's unset. Is it possible to unset it within the loop?</p>