-1

我想搜索我拥有的字符串并提取可能以 .com .net 等结尾的域名...

$string = "Just head over to nba.com";
$string = "visit cnn.net"; 

请帮我把上面的域名提取成一个变量。

先感谢您。

4

1 回答 1

1
if (preg_match_all('/\w+\.(com|net)/', $text, $matches)){
   print_r($matches);
}

第一场比赛将是:

echo $matches[0][0];
于 2013-07-29T06:21:49.000 回答