Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Parsing a line into variables?

    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

  • #2
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There may be a better or shortway, but this should work

    PHP Code:
    <?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($tempstrrpos($temp'='));  
    $temp substr($temp1strrpos($temp'.') -1);
    echo 
    '---'.$temp.'<br>';
    ?>
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •