title: Unsetting values in a foreach loop not working
body: <p>I have the array <code>$allowedViewLevels</code> with the following example elements:</p>
  
  <pre><code>Array (
      [0] =&gt; 1
      [1] =&gt; 1
      [2] =&gt; 2
      [3] =&gt; 3
      [4] =&gt; 4
      [5] =&gt; 6
      [6] =&gt; 7
      [7] =&gt; 8
      [8] =&gt; 9
      [9] =&gt; 10
      [10] =&gt; 11
      [11] =&gt; 12
  ) 
  </code></pre>
  
  <p>I want to loop trough this array and check if the values are equal to 1, 8 or 11. If so, the corresponding elements should be deleted from the array.</p>
  
  <p>For that, I used the following script:</p>
  
  <pre><code>foreach ($allowedViewLevels as $key) {
      if($key==1 || $key==8 || $key==11){
          unset($allowedViewLevels[$key]);
      } 
  };
  
  $niveis=implode(",", $allowedViewLevels);
  print $niveis;  
  </code></pre>
  
  <p>Which is returning:</p>
  
  <pre><code>1,2,3,4,6,7,8,10,11 
  </code></pre>
  
  <p>So the elements in the array containing the values 1, 8 or 11 are not being unset from it. What can be wrong with this script?</p>