Link to home
Start Free TrialLog in
Avatar of PeterdeB
PeterdeBFlag for Netherlands

asked on

How to modify this code?

Hi Folks, I have some code to query a domain but now I'd like to query multiple domains at once using a for loop or something.
Perhaps the supplied code can be turned into a function which takes a domain as param?  If you need more info please ask.

Regards Peter
<?php
require_once "Whois.php";
 
$server = "whois.denic.de";
$query  = "autoverzekering-tarieven.nl";     // get information about  this domain
$whois = new Net_Whois;
$data = $whois->query($query, $server);
echo $data;
?>

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image


<?php
function my_whois($array)
{
   require_once "Whois.php";
   $answers = array();
   $server = "whois.denic.de";
   foreach ($array as $query)
   {
      $whois = new Net_Whois;
      $answers["$query"] = $whois->query($query, $server);
      unset($whois);
   }
   return($answers);
}
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robin Uijt
Using it as a function, will get you this:

Will this do?
<?php
require_once "Whois.php";
 
function getWhoisData($domain)
{
  $server = "whois.denic.de";
  $whois = new Net_Whois;
  return $whois->query($domain, $server);
}
 
echo getWhoisData("autoverzekering-tarieven.nl");
echo getWhoisData("fietsverzekering-tarieven.nl");
//etc.
 
?>

Open in new window

Avatar of PeterdeB

ASKER

Thanks for the replies folks.
@Ray > I will post another question in an attempt to use the function you supplied.

Regards,

Peter