Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想搜索我拥有的字符串并提取可能以 .com .net 等结尾的域名...
$string = "Just head over to nba.com"; $string = "visit cnn.net";
请帮我把上面的域名提取成一个变量。
先感谢您。
if (preg_match_all('/\w+\.(com|net)/', $text, $matches)){ print_r($matches); }
第一场比赛将是:
echo $matches[0][0];