我的動機是使用php獲取域名的託管提供商。 當tracert的/跟蹤路由到任何域名(yahoo.com),它提供了:如何在不使用'http://'和'www'的情況下從php中獲取tracert/traceroute域名。作爲針?
traceroute to 72.30.2.43 (72.30.2.43), 30 hops max, 40 byte packets 1 c1.25.78ae.static.theplanet.com (174.120.37.193) 0.648 ms 0.630 ms 0.647 ms 2 te6-2.dsr02.dllstx2.networklayer.com (70.87.254.237) 0.365 ms 0.430 ms 0.462 ms 3 te7-4.dsr02.dllstx3.networklayer.com (70.87.253.121) 0.562 ms te4-3.dsr02.dllstx3.networklayer.com (70.87.255.129) 0.910 ms te4-4.dsr02.dllstx3.networklayer.com (70.87.255.133) 0.664 ms 4 ae17.bbr01.eq01.dal03.networklayer.com (173.192.18.226) 0.403 ms ae17.bbr02.eq01.dal03.networklayer.com (173.192.18.230) 0.380 ms 0.405 ms 5 ae1.bbr01.cf01.den01.networklayer.com (173.192.18.139) 14.864 ms 14.723 ms 14.770 ms 6 ae1.bbr01.cf01.den01.networklayer.com (173.192.18.139) 14.787 ms 198.32.216.25 (198.32.216.25) 14.882 ms 14.946 ms 7 198.32.216.25 (198.32.216.25) 14.863 ms ae-7.pat1.pao.yahoo.com (216.115.101.128) 38.403 ms ae-7.pat1.sjc.yahoo.com (216.115.101.149) 41.250 ms 8 ae-1-d420.msr1.sk1.yahoo.com (216.115.106.161) 38.930 ms ae-1-d400.msr1.sk1.yahoo.com (216.115.106.153) 41.643 ms ae-0-d210.msr2.sk1.yahoo.com (216.115.106.133) 38.617 ms 9 te-8-1.bas-k1.sk1.yahoo.com (68.180.160.9) 41.478 ms te-9-1.bas-k2.sk1.yahoo.com (68.180.160.15) 39.368 ms ae-0-d230.msr2.sk1.yahoo.com (216.115.106.141) 42.650 ms 10 * * te-8-1.bas-k2.sk1.yahoo.com (68.180.160.11) 41.787 ms 11 * * * 12 * * * 13 * * * 14 * * * 15 * * * 16 * * * 17 * * * 18 * * * 19 * * * 20 * * * 21 * * * 22 * * * 23 * * * 24 * * * 25 * * * 26 * * * 27 * * * 28 * * * 29 * * * 30 * * *
我想最後一個有效的域名,這是(在這種情況下):
`10 * * te-8-1.bas-k2.sk1.yahoo.com (68.180.160.11) 41.787 ms`
我可以通過使用此代碼得到這個容易(stristr()):
$a = explode("\n",$str); foreach($a as $v){ if(!stristr($v,'* * *')){ echo $v.'
'; } }
我需要這樣的結果:
yahoo.com
它應該是從10#( 10 * te-8-1.bas-k2.sk1.yahoo.com(68.180.160.11)41.787毫秒)
有沒有人有一個解決這個問題?或者如果有人在這裏更好地解決我的基本目標。
真的很感激任何幫助。
謝謝!
你會從'10 * * te-8-1.bas-k2.sk1.yahoo.co.uk(68.180.160.11)41.787 ms)'這一行中期待哪個答案?我猜'yahoo.co.uk'? – 2011-12-20 23:01:01
是的,沒錯。 – 2011-12-20 23:04:03
謝謝@Cassy – 2011-12-20 23:07:30