title: Capturing data using $ _GET in foreach ($ data as $ key => $ value) {
body: <p>In <code>id==2</code> I am not able to capture the data (<code>url</code> and <code>title</code>) of the <code>array</code> of <code>id==1</code> using <code>$ _GET</code>. Where am I going wrong?</p>
  
  <p>P.S.: I do not intend to use an external library.</p>
  
  <pre><code>&lt;?php
  $id = $_GET['id'];
  //var_dump($_GET);
  
  if ($id == 1) {
      $re = '/href="(?P&lt;link&gt;.*?)" title="(?P&lt;title&gt;.*?)" class="iGh__menu-link/';
      $html = file_get_contents('https://www.ig.com.br/');
  
      preg_match_all($re, $html, $data);
      //print_r ($data['link']);
      //print_r ($data['title']); 
      foreach ($data as $key =&gt; $value) {
  
          "http://$_SERVER[HTTP_HOST]/loja.php" . '&amp;url=' . $data['link'][$key] . '&amp;title=' . $data['title'][$key] . '&amp;s=1&amp;logo=""';
      }
  } else if ($id == 2) {
      $url = $_GET['url'];
      $title = $_GET['title'];
  }
  ?&gt;
  </code></pre>