...

View Full Version : Get an IP from a string



timgolding
08-04-2007, 04:12 AM
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.



$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

kbluhm
08-04-2007, 04:16 AM
preg_match( '/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/', $str, $m );

print_r( $m );

timgolding
08-04-2007, 03:25 PM
thanks alot



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum