I'm trying to grab the NS and A records for a list of domains I have in a table.
I've started to write this:
$domains = GetDomainsForDNS();
foreach ($domains as $domain){
$domain_id = $domain[0];
$domain = $domain[1];
$dns_records = dns_get_record($domain, DNS_NS + DNS_A);
echo $domain;
foreach($dns_records as $dns_record){
if (!$dns_record){
//var_dump($dns_record);
echo "empty";
}
}
}
$domains is the id and domains from the table that I want to check.
The Warnings I am getting are:
Warning: Invalid argument supplied for foreach() for the later foreach
And
Warning: dns_get_record(): DNS Query failed for dns_get_record
By the look of it I am getting these errors when dns_get_record() does not find anything.
I am trying to mark these domains as having an issue in the database so I need a method to detect them. I've tried empty() and other methods to detect them but everything I do brings up the php warnings above.
Is this because it's a multi-dimensional array? How do I go about doing this properly.
Thanks
As the format of the source array is not specified I guessed it would be similar to the array shown below - seems to work ok and very quickly returns the dns records for later processing
The output of which will be similar to