<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP &#8211; How to get domain name from URL?</title>
	<atom:link href="http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/feed/" rel="self" type="application/rss+xml" />
	<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/</link>
	<description>Daily Blog from Internet Entrepreneur/Webmaster</description>
	<lastBuildDate>Wed, 16 May 2012 07:15:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: prema</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26244</link>
		<dc:creator>prema</dc:creator>
		<pubDate>Mon, 07 May 2012 07:07:34 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26244</guid>
		<description>how to create own domain</description>
		<content:encoded><![CDATA[<p>how to create own domain</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mukesh</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26079</link>
		<dc:creator>Mukesh</dc:creator>
		<pubDate>Sat, 21 Apr 2012 16:23:44 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26079</guid>
		<description>Got better solution It will solve your problems.. :) 
&lt;php
print get_domain(&quot;http://whois.india.dj&quot;); // outputs &#039;india.dj&#039;

function get_domain($url)
{
  $pieces = parse_url($url);
  $domain = isset($pieces[&#039;host&#039;]) ? $pieces[&#039;host&#039;] : &#039;&#039;;
  if (preg_match(&#039;/(?P[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i&#039;, $domain, $regs)) {
    return $regs[&#039;domain&#039;];
  }
  return false;
?&gt;</description>
		<content:encoded><![CDATA[<p>Got better solution It will solve your problems.. <img src='http://corpocrat.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
&lt;php<br />
print get_domain(&quot;<a href="http://whois.india.dj&#038;quot" rel="nofollow">http://whois.india.dj&#038;quot</a> <img src='http://corpocrat.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ; // outputs &#039;india.dj&#039;</p>
<p>function get_domain($url)<br />
{<br />
  $pieces = parse_url($url);<br />
  $domain = isset($pieces[&#039;host&#039;]) ? $pieces[&#039;host&#039;] : &#039;&#039;;<br />
  if (preg_match(&#039;/(?P[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i&#8217;, $domain, $regs)) {<br />
    return $regs['domain'];<br />
  }<br />
  return false;<br />
?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mukesh</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26077</link>
		<dc:creator>Mukesh</dc:creator>
		<pubDate>Sat, 21 Apr 2012 15:56:33 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26077</guid>
		<description>the second one is not working domains such mkj.co.in india.ind.in 
etc :(</description>
		<content:encoded><![CDATA[<p>the second one is not working domains such mkj.co.in india.ind.in<br />
etc <img src='http://corpocrat.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mukesh</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26076</link>
		<dc:creator>Mukesh</dc:creator>
		<pubDate>Sat, 21 Apr 2012 15:51:35 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26076</guid>
		<description>Parse error: syntax error, unexpected &#039;=&#039; on line 6 :(</description>
		<content:encoded><![CDATA[<p>Parse error: syntax error, unexpected &#8216;=&#8217; on line 6 <img src='http://corpocrat.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mukesh</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26075</link>
		<dc:creator>Mukesh</dc:creator>
		<pubDate>Sat, 21 Apr 2012 15:40:26 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-26075</guid>
		<description>Hoping it will help me.. ;)
Thanks a Lot</description>
		<content:encoded><![CDATA[<p>Hoping it will help me.. <img src='http://corpocrat.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Thanks a Lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PHP – How to get domain name from URL? &#124; Alagirivimal Blog</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-24679</link>
		<dc:creator>PHP – How to get domain name from URL? &#124; Alagirivimal Blog</dc:creator>
		<pubDate>Thu, 01 Mar 2012 02:49:54 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-24679</guid>
		<description>[...] http://domain.co.uk =&gt; gives =&gt; domain.co.uk http://domain.co.uk/users/main.html =&gt; gives =&gt; domain.co.uk http://www.domain.co.uk =&gt; gives =&gt; domain.co.uk www.domain.co.uk =&gt; gives =&gt; domain.co.uk   ? [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://domain.co.uk" rel="nofollow">http://domain.co.uk</a> =&gt; gives =&gt; domain.co.uk <a href="http://domain.co.uk/users/main.html" rel="nofollow">http://domain.co.uk/users/main.html</a> =&gt; gives =&gt; domain.co.uk <a href="http://www.domain.co.uk" rel="nofollow">http://www.domain.co.uk</a> =&gt; gives =&gt; domain.co.uk <a href="http://www.domain.co.uk" rel="nofollow">http://www.domain.co.uk</a> =&gt; gives =&gt; domain.co.uk   ? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fawzi</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-23880</link>
		<dc:creator>fawzi</dc:creator>
		<pubDate>Thu, 16 Feb 2012 05:57:52 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-23880</guid>
		<description>Here is what i used to get the domain after reading the above:
// parse url to compnents e.g.: scheme=&gt; http; host=&gt; autos.yahoo.co.uk; path=&gt; /new-cars.html
$parse = parse_url($url);
// Extract domain name from host compnent.
$url_domain_dot_ar = explode(&quot;.&quot;, $parse[host]);
$url_domain = $url_domain_dot_ar[1] . &#039;.&#039; . $url_domain_dot_ar[2];
if ($url_domain_dot_ar[2] != &quot;com&quot;) { $url_domain = $url_domain . &#039;.&#039; . $url_domain_dot_ar[3];}

echo &#039;Domain from dot array parsed is : &#039; . $url_domain . &quot;&quot;;

It does account for subdomain.domain.com and for domain.co.uk.</description>
		<content:encoded><![CDATA[<p>Here is what i used to get the domain after reading the above:<br />
// parse url to compnents e.g.: scheme=&gt; http; host=&gt; autos.yahoo.co.uk; path=&gt; /new-cars.html<br />
$parse = parse_url($url);<br />
// Extract domain name from host compnent.<br />
$url_domain_dot_ar = explode(&#8220;.&#8221;, $parse[host]);<br />
$url_domain = $url_domain_dot_ar[1] . &#8216;.&#8217; . $url_domain_dot_ar[2];<br />
if ($url_domain_dot_ar[2] != &#8220;com&#8221;) { $url_domain = $url_domain . &#8216;.&#8217; . $url_domain_dot_ar[3];}</p>
<p>echo &#8216;Domain from dot array parsed is : &#8216; . $url_domain . &#8220;&#8221;;</p>
<p>It does account for subdomain.domain.com and for domain.co.uk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evgen</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-23688</link>
		<dc:creator>Evgen</dc:creator>
		<pubDate>Wed, 01 Feb 2012 10:45:24 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-23688</guid>
		<description>function getDomain()
{
    preg_match(&quot;#^.*?([a-z0-9-]+\.[a-z]{0,3})$#i&quot;,   $_SERVER[&#039;HTTP_HOST&#039;], $matches);
    return $matches[1];
}</description>
		<content:encoded><![CDATA[<p>function getDomain()<br />
{<br />
    preg_match(&#8220;#^.*?([a-z0-9-]+\.[a-z]{0,3})$#i&#8221;,   $_SERVER['HTTP_HOST'], $matches);<br />
    return $matches[1];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peak</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-23175</link>
		<dc:creator>peak</dc:creator>
		<pubDate>Tue, 13 Dec 2011 16:48:49 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-23175</guid>
		<description>$w_url[]=weburl.split[&#039;/&#039;];</description>
		<content:encoded><![CDATA[<p>$w_url[]=weburl.split['/'];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tired</title>
		<link>http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-20322</link>
		<dc:creator>tired</dc:creator>
		<pubDate>Sat, 13 Aug 2011 06:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/#comment-20322</guid>
		<description>&gt;Guillaume
&quot;Please sometimes read PHP Manual !&quot;

Or you could try to read the question!

He wants to get rid of the www (or any other subdomain) from the host and show only the domain.</description>
		<content:encoded><![CDATA[<p>&gt;Guillaume<br />
&#8220;Please sometimes read PHP Manual !&#8221;</p>
<p>Or you could try to read the question!</p>
<p>He wants to get rid of the www (or any other subdomain) from the host and show only the domain.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

