title: How to remove an element of array in foreach loop?
body: <p>I want to loop through an array and check if some elements is equal to a specific condition . 
  For example , I want to remove the element contains <code>"O"</code> , so I can do in this way ..</p>
  
  <pre><code>@Array = ("Apple","Orange","Banana");
  for ($i=0 ; $i &lt;= $#Array ; $i++) {
      if( index($Array[$i],"O") &gt;= 0 ) {
          splice(@Array,$i,1);
      }
  }
  </code></pre>
  
  <p>but if I want to use <code>foreach</code> loop to replace <code>for</code> loop , how do I do ? because in <code>foreach</code> loop , there is no index so I can't use <code>splice</code> , unless I set a variable to store it .</p>