title: change initial array inside the foreach loop?
body: <p>i want to have a foreach loop where the initial array is changed inside the loop.</p>
  
  <p>eg.</p>
  
  <pre><code>$array = array('red', 'blue');
  foreach($array as $key =&gt; $value) {
      $array[] = 'white';
      echo $value . '&lt;br /&gt;';
  }
  </code></pre>
  
  <p>in this loop the loop will print out red and blue although i add another element inside the loop.</p>
  
  <p>is there any way to change the initial array inside the loop so new elements will be added and the foreach will use the new array whatever is changed?</p>
  
  <p>i need this kind of logic for a specific task:</p>
  
  <p>i will have a if statement that search for a link. if that link exists, it is added to the array. the link content will be fetched to be examined if it contains another link. if so, this link is added, and the content will be fetched, so on so forth.. when no link is further founded, the foreach loop will exit</p>