title: PHP file_get_contents foreach
body: <p>I've found an existing script on the internet that grabs data from WHOIS servers and extracts the relevent data (Eg. Expiry date, Status). As it was long abandoned I have been modifying it and created my own <code>script.php?id=domain.com</code> which lets me enter any domain and whois data comes up,
  What I'm having trouble with is I have my whois.php file which I want to grab a list of domains out of my MySQL database and attempt to extract the Expiry/Status data of each domain using (file_get_contents to my script.php and foreach) then update the database with the relevant information.
  I'm fairly certain I have coded everything apart from the "<strong>Foreach</strong>" &amp; "<strong>File_get_contents</strong>" part right therefore my script encounters errors.</p>
  
  <blockquote>
    <p>"Warning: Invalid argument supplied for foreach() in /home/<em>user</em>/public_html/mydomain.com/domains/whois.php on line 39"</p>
  </blockquote>
  
  <p>is the error I receive.</p>
  
  <p>Snippet of my <strong>whois.php</strong>:</p>
  
  <pre><code>include("database.php");
  // Select one domain from the database that hasn't been checked yet
  $sql = "SELECT domainName from domains WHERE 1 ORDER BY lastChecked ASC";
  $result = mysql_query($sql);
  $row = mysql_fetch_row($result);
  $domain = $row[0];
  
  if(mysql_num_rows($result) == 0){
      die("No domains found in the database.");
  }
  
  // Grab the WHOIS information for the domain selected
  // ---------------------------------------------------------------
  $domainExt = substr($domain, -3); // grab the domain extension
  
  
  //var_dump($whois);
  
  
  $arr = array($content);
  foreach($arr as $id) {          
      echo $id, '&lt;br&gt;';           
      $data = file_get_contents('http://codestrike.net/domains/script.php?id='.$domain.'');
      echo $data, '&lt;br&gt;';
  }
  
  
  foreach($data as $whoisline){
      if(strstr($whoisline,"Expiration")){
          $whoisline = str_replace("Expire Date:","",$whoisline);
          $whoisline = trim($whoisline);
          $expiration = substr($whoisline,0,11);
      }
  
      if(strstr($whoisline,"Status")){
          $statusline = $whoisline;
      }
  }
  
  $status = str_replace("Status:","",$statusline);
  $status = trim($status);
  </code></pre>
  
  <p>Script.php?id=domain.com works fine, its just a matter of having the whois.php finding     the expiry date/status for each domain out of my MySQL Database.</p>
  
  <p>Cheers.</p>