...

View Full Version : Parsing a line into variables?



thewird
09-01-2006, 03:08 AM
I found a way to get a nslookup through php. However, I'm not sure how to parse it. Basically this is the output I get...


Server: 127.0.0.1 Address: 127.0.0.1#53 Non-authoritative answer: oilfight.com nameserver = ns1.oilfight.com. oilfight.com nameserver = ns2.oilfight.com. Authoritative answers can be found from: 0

How would I parse the nameservers out of that and store them in variables. I know sites sometimes have more then one nameserver so I'd like to store up to the first 4 nameservers if available. Could anyone help me with this please? THanks.

thewird

musher
09-01-2006, 04:30 AM
There may be a better or shortway, but this should work


<?php
$temp ="Server: 127.0.0.1 Address: 127.0.0.1#53 Non-authoritative answer: oilfight.com nameserver = ns1.oilfight.com. oilfight.com nameserver = ns2.oilfight.com. Authoritative answers can be found from: 0";

$temp = substr($temp, strrpos($temp, '='));
$temp = substr($temp, 1, strrpos($temp, '.') -1);
echo '---'.$temp.'<br>';
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum