PHP whois array results problem

the below code returns my array ok but for some reason i cannot get the nameservers from the array.
i must be missing something simple, any suggestions ?


The result from the search is as below
[QUOTE]
Array
(
    [regyinfo] => Array
        (
            [referrer] => http://www.aunic.net
            [registrar] => AU-NIC
            [servers] => Array
                (
                    [0] => Array
                        (
                            [server] => whois.aunic.net
                            [args] => johnsons.net.au
                            [port] => 43
                        )

                )

            [type] => domain
        )

    [regrinfo] => Array
        (
            [domain] => Array
                (
                    [name] => johnsons.net.au
                    [changed] => 2008-06-30
                    [sponsor] => Melbourne IT
                    [status] => ok
                    [nserver] => Array
                        (
                            [ns1.johnsons.net.au] => 0.0.0.0
                            [ns2.johnsons.net.au] => 0.0.0.0
                        )

                )

            [owner] => Array
                (
                    [organization] => Johnsons
                    [handle] => OTHER N/A
                    [name] => Tracey Johnson
                )

            [registered] => yes
        )

    [rawdata] => Array
        (
            [0] => Domain Name:                     johnsons.net.au
            [1] => Last Modified:                   30-Jun-2008 08:16:12 UTC
            [2] => Registrar ID:                    Melbourne IT
            [3] => Registrar Name:                  Melbourne IT
            [4] => Status:                          ok
            [5] =>
            [6] => Registrant:                      Johnsons Gateway
            [7] => Registrant ID:                   OTHER N/A
            [8] => Eligibility Type:                Other
            [9] => Eligibility Name:                Johnsons Internet Services
            [10] =>
            [11] => Registrant Contact ID:           Z110566996728342
            [12] => Registrant Contact Name:         Tracey Johnson
            [13] => Registrant Contact Email:        Visit whois.ausregistry.com.au for Web based WhoIs
            [14] =>
            [15] => Tech Contact ID:                 Z110566996728342
            [16] => Tech Contact Name:               Tracey Johnson
            [17] => Tech Contact Email:              Visit whois.ausregistry.com.au for Web based WhoIs
            [18] =>
            [19] => Name Server:                     ns1.johnsons.net.au
            [20] => Name Server IP:                  0.0.0.0
            [21] => Name Server:                     ns2.johnsons.net.au
            [22] => Name Server IP:                  0.0.0.0
        )

)
[/QUOTE]

//details changed for security



include ("./phpwhois-4.1.3/whois.main.php");
 
 
$whois = new Whois();
$result = $whois->Lookup($domain_check);
 
 
$registrar = $result['regrinfo']['domain']['sponsor'];
$nameserver1 = $result['regrinfo']['domain']['nserver'][0];
$nameserver2 = $result['regrinfo']['domain']['nserver'][1];
$status = $result['regrinfo']['domain']['status'];
$owner = $result['regrinfo']['owner']['name'];

Open in new window

CiphertelAsked:
Who is Participating?
 
albrieuCommented:
Try some like this code
include ("./phpwhois-4.1.3/whois.main.php");
 
 
$whois = new Whois();
$result = $whois->Lookup($domain_check);
 
 
$registrar = $result['regrinfo']['domain']['sponsor'];
 
$nameserver = array_keys($result['regrinfo']['domain']['nserver']);
 
$nameserver1 = $nameserver[0];
$nameserver2 = $nameserver[1];
 
$status = $result['regrinfo']['domain']['status'];
$owner = $result['regrinfo']['owner']['name'];}

Open in new window

0
 
albrieuCommented:
the problem is you are use the incorrect key

$nameserver1 = $result['regrinfo']['domain']['nserver'][ns1.johnsons.net.au];
 
but i think the key is variable and you most to parse the results in other array to get the results.



//count how nameservers contains
$total_nameservers=count($result['regrinfo']['domain']['nserver']);
$nameserver=array();
if($total_nameservers>0)
{
 foreach($result['regrinfo']['domain']['nserver'] as $key_nameserv=>$ip_nameserv)
 {
   $nameserver[]=$key_nameserv;
   
 }
}else{
  echo "no nameservers";
}
 
print_r($nameserver);

Open in new window

0
 
CiphertelAuthor Commented:
My understanding was the data was already formatted into an array and all i had to do was reference this directly
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
albrieuCommented:
is a key of array ns1.johnsons.net.au
for sample:
$nameserver1 = $result['regrinfo']['domain']['nserver'][ns1.johnsons.net.au];

$nameserver1 will be get the ip not the key name

if you use array_keys($result['regrinfo']['domain']['nserver'])

you get an array of keys


0
 
CiphertelAuthor Commented:
ahh of course now i understand, thank you very much.

now i just need to work out a way to query the 'A" and 'MX' records as well.
Cheers
0
 
albrieuCommented:
your welcome

thanks for the points
0
 
albrieuCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.