<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">

<channel>
<title>Topic &#x27;PHP: Get TLD from URL&#x27; in forum &#x27;Webmasters and Developers&#x27; - dslreports.com</title>
<link>http://www.dslreports.com/forum/PHP-Get-TLD-from-URL-21595938</link>
<description></description>
<language>en</language>
<pubDate>Sun, 19 May 2013 15:58:50 EDT</pubDate>
<lastBuildDate>Sun, 19 May 2013 15:58:50 EDT</lastBuildDate>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21809269</link>
<description><![CDATA[JAAulde posted : I forgot an ELSE... look at &raquo;<A HREF="http://codepad.org/NGlABcAC" >codepad.org/NGlABcAC</A><br>You can add more logic if you don't want ANY invlaid domains being returned, even when max node count is greater than 0.<br><br>But like  PetePuma <A HREF="/useremail/u/644121"><IMG SRC="http://i.dslr.net/bb/profile.gif" ALT="See Profile" BORDER=0 WIDTH=16 HEIGHT=11></A> said, there is no catch all for this.  Some of it is going to have to be implementation specific.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21809269</guid>
<pubDate>Mon, 26 Jan 2009 14:48:35 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21809220</link>
<description><![CDATA[PetePuma posted : I can't think of a one-size-fits-all solution that doesn't incorporate a list of all possible TLDs and adjusts accordingly.  And even then, it's probably not precise.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21809220</guid>
<pubDate>Mon, 26 Jan 2009 14:40:07 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21809203</link>
<description><![CDATA[Jafo232 posted : Seems to cause issues when dealing with domains like:<br><br>somewhere.co.uk..<br><br>Any idea of a work around?]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21809203</guid>
<pubDate>Mon, 26 Jan 2009 14:37:21 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21799981</link>
<description><![CDATA[JAAulde posted : Since this topic keeps popping back up, I've modified my previous code to allow for a second parameter which limits the output to a particular number of nodes.<br>&raquo;<A HREF="http://codepad.org/4lyu1XMh" >codepad.org/4lyu1XMh</A>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21799981</guid>
<pubDate>Sat, 24 Jan 2009 15:22:44 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21799846</link>
<description><![CDATA[jayco437 posted : Not quite the PHP expert myself, but wouldn't something like this work just fine: &raquo;<A HREF="http://us.php.net/function.parse-url" >us.php.net/function.parse-url</A><br><br>Edit: Nevermind, just saw the actual code sample that was posted, and it used parse_url.  My bad.  I was looking at the question and the replies using regex and I know Python and Ruby both have tools to manage urls and uris, figured PHP should have one too.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21799846</guid>
<pubDate>Sat, 24 Jan 2009 14:49:40 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21799566</link>
<description><![CDATA[vollie posted : Mh, forgot about that one, thanks. Luckily I needed the subdomain as well (whereby (?:.+://)?([^/]+)(?:/?.*)? does the trick), but in this case it seems one needs to stick with JAAulde's answer indeed.<br><small>--<br>Chris Volwerk<br>&raquo;<A HREF="http://boe-end.nl/" >boe-end.nl/</A></small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21799566</guid>
<pubDate>Sat, 24 Jan 2009 13:43:25 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21754012</link>
<description><![CDATA[PToN posted : &raquo;<A HREF="http://regexlib.com" >regexlib.com</A>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21754012</guid>
<pubDate>Fri, 16 Jan 2009 15:56:31 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21753974</link>
<description><![CDATA[PetePuma posted : This might not work for .co.uk URLs, where you want the last *3* parts of the URL.  The country domains are a tricky bunch, and are not consistent.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21753974</guid>
<pubDate>Fri, 16 Jan 2009 15:50:41 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21749433</link>
<description><![CDATA[vollie posted : ok, so i was looking for a straight-out answer to your question, then figured it out myself, and figured i might as well post it...<br>So, without further ado:<br><br>(?:.+://)?(?:[^/]*\.)?([^/]+\.[^/]+)(?:/?.*)?<br>replaced by $1<br><br>will strip anything other then the bla.bla before the / in any url, reliable as hell.<br><br>Oh, since you're using php; don't forget the starting and ending thing so like:<br>preg_replace('@(?:.+://)?(?:[^/]*\.)?([^/]+\.[^/]+)(?:/?.*)?@', '$1', $url);<br><br> (PS. if you do happen to find some way to beat it, please inform me ;))<br><small>--<br>Chris Volwerk<br>&raquo;<A HREF="http://boe-end.nl/" >boe-end.nl/</A></small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21749433</guid>
<pubDate>Thu, 15 Jan 2009 21:15:35 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596168</link>
<description><![CDATA[Jafo232 posted : JAAulde, shot your a private message..]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596168</guid>
<pubDate>Wed, 17 Dec 2008 11:56:44 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596102</link>
<description><![CDATA[Jafo232 posted : Thanks JAAulde!  I will try this out.  Hopefully it will work better than some of the other code I have tinkered with.<br><small>--<br><A HREF="http://www.worldwidecreations.com">Custom PHP/Perl Development.  Vbulletin And Wordpress Mods Too!</a></small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596102</guid>
<pubDate>Wed, 17 Dec 2008 11:44:04 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596083</link>
<description><![CDATA[JAAulde posted : Ahh, I see.  Very well then:<br><br>&raquo;<A HREF="http://codepad.org/UXGS161q" >codepad.org/UXGS161q</A><br><br>If both TLD and "top level host" are found, you should get them back.  Otherwise you get an empty string.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596083</guid>
<pubDate>Wed, 17 Dec 2008 11:41:00 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596049</link>
<description><![CDATA[Jafo232 posted : Actually your code is right, what I asked for is wrong.  I need the domain name with the TLD, example:<br><br><pre class="brush: text">http://www.dslreports.com/some/path/to/a/file.ext?name=value&#012; &#012;</pre><!--end code block--><br>To return just:<br><br>dslreports.com<br><br>Same with any URL:<br><br><pre class="brush: text">http://somesubdomain.domain.com/path/to/somewhere&#012; &#012;</pre><!--end code block--><br><small>--<br><A HREF="http://www.worldwidecreations.com">Custom PHP/Perl Development.  Vbulletin And Wordpress Mods Too!</a></small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596049</guid>
<pubDate>Wed, 17 Dec 2008 11:35:33 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596045</link>
<description><![CDATA[JAAulde posted : <div class="bquote"><small>said by <a href="/profile/705861" onClick="this.blur(); return popup(event,'/uidpop?ajh=1&uid=705861');">Jafo232</a>:</small><br><br><div class="bquote"><small>said by <a href="/profile/386501" onClick="this.blur(); return popup(event,'/uidpop?ajh=1&uid=386501');">JAAulde</a>:</small><br><br>Code and output: &raquo;<A HREF="http://codepad.org/LSQ1VyyL" >codepad.org/LSQ1VyyL</A><br><br><b>Edit:</b>  this <i>could</i> be done with a regex, but URLs can vary so widely that I'd rather take a few steps and use built in functions where possible.  I think this is more reliable in <i>this</i> case.<br> </div>I tried that code and the output was:<br><br>"com"<br> </div>Which would be the <i><A HREF="http://en.wikipedia.org/wiki/Top-level_domain">TLD</a></i>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596045</guid>
<pubDate>Wed, 17 Dec 2008 11:34:50 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596038</link>
<description><![CDATA[Jafo232 posted : <div class="bquote"><small>said by <a href="/profile/386501" onClick="this.blur(); return popup(event,'/uidpop?ajh=1&uid=386501');">JAAulde</a>:</small><br><br>Code and output: &raquo;<A HREF="http://codepad.org/LSQ1VyyL" >codepad.org/LSQ1VyyL</A><br><br><b>Edit:</b>  this <i>could</i> be done with a regex, but URLs can vary so widely that I'd rather take a few steps and use built in functions where possible.  I think this is more reliable in <i>this</i> case.<br> </div>I tried that code and the output was:<br><br>"com"<br><small>--<br><A HREF="http://www.worldwidecreations.com">Custom PHP/Perl Development.  Vbulletin And Wordpress Mods Too!</a></small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596038</guid>
<pubDate>Wed, 17 Dec 2008 11:32:53 EDT</pubDate>
</item>

<item>
<title>Re: PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596021</link>
<description><![CDATA[JAAulde posted : Code and output: &raquo;<A HREF="http://codepad.org/LSQ1VyyL" >codepad.org/LSQ1VyyL</A><br><br><b>Edit:</b>  this <i>could</i> be done with a regex, but URLs can vary so widely that I'd rather take a few steps and use built in functions where possible.  I think this is more reliable in <i>this</i> case.]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/Re-PHP-Get-TLD-from-URL-21596021</guid>
<pubDate>Wed, 17 Dec 2008 11:30:10 EDT</pubDate>
</item>

<item>
<title>PHP: Get TLD from URL</title>
<link>http://www.dslreports.com/forum/PHP-Get-TLD-from-URL-21595938</link>
<description><![CDATA[Jafo232 posted : Regex has never been my expertise, so I am going to ask here. :)<br><br>I have a form where a URL is being submitted.  My task is to parse the URL and get just the top level domain (i.e. dslreports.com) and save that value.  I cannot seem to find any decent existing code that does this in a bullet proof way.  Anyone have any ideas?<br><small>--<br><A HREF="http://www.worldwidecreations.com">Custom PHP/Perl Development.  Vbulletin And Wordpress Mods Too!</a></small>]]></description>
<guid isPermaLink="true">http://www.dslreports.com/forum/PHP-Get-TLD-from-URL-21595938</guid>
<pubDate>Wed, 17 Dec 2008 11:13:52 EDT</pubDate>
</item>

</channel>
</rss>
