【php开源代码栏目提醒】:网学会员为广大网友收集整理了,preg_match.php,希望对大家有所帮助!
<?php
preg_match("/^(http:\/\/)?([^\/]+)/i","http://www.csdn.net", $matches);
$host = $matches[2];
echo "<pre>";
print_r($matches);
echo "</pre>";
preg_match("/[^\.]+\.[^\.]+$/", $host, $matches);
echo "<br>域名: {$matches[0]}\n";
?>