title: Using nested foreach loop on same array
body: <p>Is it ok to loop array again in nested loop and also change the array?</p>
  
  <p>I've an URL's array with entries(as array key) of either an URL or domain:example.com</p>
  
  <p>In case of this entry : domain:example.com I want to remove all URLS containing example.com as domain: </p>
  
  <pre><code>foreach (array_keys($urls1) as $line) {
          if (preg_match('/domain:(.*)/i', $line, $matches)) {
              $domain = $matches[1];
              foreach (array_keys($urls1) as $line2) {
                  if ($url_domains[$line2] == $domain) {
                      unset($urls1[$line2]);
                  }
              }
          }
      }
  </code></pre>