title: Check multiple whois requests in a textarea
body: <p>I would like to create a whois function that can check availability for multiple domains (many different words at the same time).</p>
  
  <p>I have this script which works for one single word. How can I get it to check multiple words (one word on each row in the textarea)?</p>
  
  <p>For example if I type in to following in the textarea:</p>
  
  <p>goodword</p>
  
  <p>averygoodword</p>
  
  <p>thisisagreatword</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;?php function checkDomain($domain,$server,$findText){
    // Open a socket connection to the whois server
    $con = fsockopen($server, 43);
    if (!$con) return false;
  
    // Send the requested doman name
    fputs($con, $domain."\r\n");
  
    // Read and store the server response
    $response = ' :';
    while(!feof($con)) {
    $response .= fgets($con,128);
    }
  
    // Close the connection
    fclose($con);
  
    // Check the response stream whether the domain is available
    if (strpos($response, $findText)){
    return true;
    }
    else {
    return false;
    }
    }
  
    function showDomainResult($domain,$server,$findText){
    if (checkDomain($domain,$server,$findText)){
    echo "&lt;div id='left'&gt;$domain&lt;/div&gt;&lt;div id='next'&gt;AVAILEBLE&lt;/div&gt;&lt;div id='nycontainer'&gt;&lt;/div&gt;";
    }
    else echo "&lt;div id='left'&gt;$domain&lt;/div&gt;&lt;div id='next'&gt;TAKEN&lt;/div&gt;&lt;div id='nycontainer'&gt;&lt;/div&gt;";
    }
    ?&gt;
  
    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"&gt;
    &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;&lt;?php $sidtitel ?&gt;&lt;/title&gt;
    &lt;link href="exempel1.css" rel="stylesheet" type="text/css" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
  
    &lt;div id="titel"&gt; &lt;h1&gt;Search domain&lt;/h1&gt;&lt;/div&gt;
    &lt;div id="main"&gt;
    &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post" name="domain" id="domain"&gt;
    &lt;textarea name="domainname"&gt;&lt;/textarea&gt;
  
    &lt;input type="checkbox" name="all" checked /&gt;All
    &lt;input type="checkbox" name="se"/&gt;.se
    &lt;input type="checkbox" name="nu"/&gt;.nu
    &lt;input type="checkbox" name="eu"/&gt;.eu
    &lt;input type="checkbox" name="biz"/&gt;.biz
  
    &lt;input type="checkbox" name="com"/&gt;.com
    &lt;input type="checkbox" name="net"/&gt;.net
    &lt;input type="checkbox" name="org"/&gt;.org
    &lt;input type="checkbox" name="info"/&gt;.info
  
  
    &lt;input class="text" type="submit" name="submitBtn" value="Sök domännamn"/&gt;
  
    &lt;/form&gt;
  
    &lt;?php
    if (isset($_POST['submitBtn'])){
    $domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
    $d_all = (isset($_POST['all'])) ? 'all' : '';
    $d_se = (isset($_POST['se'])) ? 'se' : '';
    $d_nu = (isset($_POST['nu'])) ? 'nu' : '';
    $d_eu = (isset($_POST['eu'])) ? 'eu' : '';
    $d_biz = (isset($_POST['biz'])) ? 'biz' : '';
    $d_com = (isset($_POST['com'])) ? 'com' : '';
    $d_net = (isset($_POST['net'])) ? 'net' : '';
    $d_org = (isset($_POST['org'])) ? 'org' : '';
    $d_info = (isset($_POST['info'])) ? 'info' : '';
  
    // Check domains only if the base name is big enough
    if (strlen($domainbase)&gt;2){
    ?&gt;
    &lt;h1&gt;Results&lt;/h1&gt;
    &lt;div id="result"&gt;
    &lt;?php
    if (($d_se != '') || ($d_all != '') ) showDomainResult($domainbase.".se",'whois.iis.se','not found');
    if (($d_nu != '') || ($d_all != '') ) showDomainResult($domainbase.".nu",'whois.nic.nu', 'NO MATCH for');
    if (($d_eu != '') || ($d_all != '') ) showDomainResult($domainbase.".eu",'whois.eu','AVAILABLE');
    if (($d_biz != '') || ($d_all != '') ) showDomainResult($domainbase.".biz",'whois.nic.biz','Not found');
    if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');
    if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');
    if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND');
    if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND');
    ?&gt;
    &lt;/div&gt;&lt;/div&gt;
    &lt;?php
    }
    }
    ?&gt;
    &lt;/body&gt;
  </code></pre>