mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
556521586c
commit
c46aa354dc
1 changed files with 7 additions and 4 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue