The first loop gets the 2 values for hostkarma just fine. The 2nd loop fails for accredit.habeas and I get “Invalid argument supplied for foreach() on line 11”. Where am I going wroge with the “foreach($value as $val)” loop?
$hosts = array('209.49.180.233','209.49.180.234');
foreach ($hosts as $host) // Loop for IP addresses
{
$rbls = array('hostkarma.junkemailfilter.com','accredit.habeas.com');
foreach ($rbls as $rbl) // Loop for domains
{
$hostname = gethostbyaddr( $host );
$lookup = $hostname . '.' . $rbl;
$value = gethostbynamel($lookup);
foreach($value as $val) // loop for multiple record/code values
{
echo $host, $rbl, $val . "
";
}
}
}
You must add:
just before
foreach($value as $val)line.For the cases when
gethostbynamelis failing its return value$valueis not an array hence causingInvalid argument supplied for foreach()error.