fix example three

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@33413 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Monte Ohrt 2000-10-05 16:40:11 +00:00
parent 556521586c
commit c46aa354dc

View file

@ -120,10 +120,13 @@ if (preg_match ("/\bweb\b/i", "PHP is the website scripting language of choice."
<example>
<title>Getting the domain name out of a URL</title>
<programlisting role="php">
preg_match("/^(.*)([^\.]+\.[^\.]+)(\/.*)?/U",
"http://www.php.net/index.html", $matches);
// show the second parenthesized subpattern
echo "domain name is: ".$matches[2]."\n";
// get host name from URL
preg_match("/^(http:\/\/)?([^\/]+)/i",
"http://www.php.net/index.html", $matches);
$host = $matches[2];
// get last two segments of host name
preg_match("/[^\.\/]+\.[^\.\/]+$/",$host,$matches);
echo "domain name is: ".$matches[0]."\n";
</programlisting>
</example>
This example will produce: