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 3 of 3
  1. #1
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts

    Get an IP from a string

    I need to find a way to extract an IP from a string. The string is passed to me with the following command which will only work on windows machines.

    PHP Code:
    $server_ip=shell_exec('ipconfig.exe | find "IP Address" | find /v " 0.0.0.0"'); 
    now i need to take just the IP xx.xx.xx.xx part
    You can not say you know how to do something, until you can teach it to someone else.

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    preg_match'/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/'$str$m );

    print_r$m ); 

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    thanks alot
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

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