note 107346 added to function.gethostbyname
| From: | EmmettBrosnan | Date: | Wed, 01 Feb 2012 23:09:52 +0000 |
| Subject: | note 107346 added to function.gethostbyname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185825@lists.php.net to get a copy of this message | ||
Grabbing IPs for multiple hosts:
<?php
function getAddrByHost($hosts, $timeout = 3) {
$returnString = '';
foreach ($hosts as $host) {
$query =
nslookup -timeout=$timeout -retry=1 $host;
if (preg_match('/\nAddress: (.*)\n/', $query, $matches))
$returnString .= trim($matches[1]) . '<br>';
$returnString .= $host . '<br>';
}
return $returnString;
}
$hostArray[] = 'www.domain1.com';
$hostArray[] = 'www.domain2.com';
//$hostArray[] = 'www.domain3.com';
//$hostArray[] = 'www.domain4.com';
$returnString = getAddrByHost($hostArray);
echo $returnString;
?>
----
Server IP: 69.147.83.197
Probable Submitter: 2.103.46.179
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyname.php
Edit -- https://master.php.net/note/edit/107346
Del: integrated -- https://master.php.net/note/delete/107346/integrated
Del: useless -- https://master.php.net/note/delete/107346/useless
Del: bad code -- https://master.php.net/note/delete/107346/bad+code
Del: spam -- https://master.php.net/note/delete/107346/spam
Del: non-english -- https://master.php.net/note/delete/107346/non-english
Del: in docs -- https://master.php.net/note/delete/107346/in+docs
Del: other reasons-- https://master.php.net/note/delete/107346
Reject -- https://master.php.net/note/reject/107346
Search -- https://master.php.net/manage/user-notes.php