工具建议顶级域名

I am creating a tool for our customers to check if their domain name exists. I plan on using the gethostbyname($domain) function. But, I want to pre-program other TLD's that would be checked along with their preferred TLD (sent through a form). I don't really know where to start here so I included my example below for user suggestions.

    // SUPPORTED TOP-LEVEL DOMAIN NAMES (TLDS)
$TLD['COMING_SOON'] = ".REALTY, .CONSTRUCTION"; 
$TLD['CURRENT']     = ".COM, .ORG, .US";

    // RECEIVE FORM DATA AND STRIP TAGS

$SOURCE =   $_SERVER['HTTP_REFERER'];
$DOMAIN =   strip_tags($_POST['domain_name']);
$TLD    =   strip_tags($_POST['tld']);
$REQ    =   $DOMAIN.$TLD;

    // CHECK CLIENT'S PREFERRED DOMAIN
     if ( gethostbyname($REQ) != $REQ ) {
      echo "DNS Record found";
     } else {
      echo "NO DNS Record found";
    }

     // TO DO: CHECK ALTERNATIVE TOP-LEVEL DOMAINS

     // TO DO: SOMEHOW SEARCH THROUGH THE $TLD ARRAY, COMPARE, AND GIVE RESULT

gethostbyname($domain) will not be sufficient; it will only tell you if the domain is active, not whether it is available for purchase or not.

To find out whether it's actually available to buy, you will need to query the relevant WHOIS service for each domain type. But this will differ for each domain type, and parsing the resulting data can be a pain, so you would be better off using an API

The registrars that you're using to register the domains should also be able to provide you with an API that you can call. Contact them and find out what they have and how to use it. That's the best option.