site Search:


 
    All Forums Hot Topics Gallery






how-to block ads


 
Search Topic:
Share Topic
Posting?
Post a:
Post a:
Links: ·How To Get Noticed ·Web Monks FAQ ·Webhosting FAQ ·Posting Code ·How To Post ·Webhosting forum
AuthorAll Replies


JAAulde
Web Developer
Premium,MVM
join:2001-05-09
Williamsport, MD
kudos:3

1 edit

reply to Jafo232

Re: PHP: Get TLD from URL

Code and output: »codepad.org/LSQ1VyyL

Edit: this could 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 this case.


Jafo232
You Can't Spell Democrat Without Rat.
Premium
join:2002-10-17
Boonville, NY

said by JAAulde:

Code and output: »codepad.org/LSQ1VyyL

Edit: this could 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 this case.
I tried that code and the output was:

"com"
--
Custom PHP/Perl Development. Vbulletin And Wordpress Mods Too!


JAAulde
Web Developer
Premium,MVM
join:2001-05-09
Williamsport, MD
kudos:3

said by Jafo232:

said by JAAulde:

Code and output: »codepad.org/LSQ1VyyL

Edit: this could 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 this case.
I tried that code and the output was:

"com"
Which would be the TLD


Jafo232
You Can't Spell Democrat Without Rat.
Premium
join:2002-10-17
Boonville, NY

1 edit

reply to Jafo232
Actually your code is right, what I asked for is wrong. I need the domain name with the TLD, example:

http://www.dslreports.com/some/path/to/a/file.ext?name=value
 

To return just:

dslreports.com

Same with any URL:

http://somesubdomain.domain.com/path/to/somewhere
 

--
Custom PHP/Perl Development. Vbulletin And Wordpress Mods Too!


JAAulde
Web Developer
Premium,MVM
join:2001-05-09
Williamsport, MD
kudos:3

1 edit

Ahh, I see. Very well then:

»codepad.org/UXGS161q

If both TLD and "top level host" are found, you should get them back. Otherwise you get an empty string.



Jafo232
You Can't Spell Democrat Without Rat.
Premium
join:2002-10-17
Boonville, NY

Thanks JAAulde! I will try this out. Hopefully it will work better than some of the other code I have tinkered with.
--
Custom PHP/Perl Development. Vbulletin And Wordpress Mods Too!



Jafo232
You Can't Spell Democrat Without Rat.
Premium
join:2002-10-17
Boonville, NY

reply to JAAulde
JAAulde, shot your a private message..


Thursday, 23-May 03:25:45 Terms of Use & Privacy | feedback | contact | Hosting by nac.net - DSL,Hosting & Co-lo
over 13.5 years online © 1999-2013 dslreports.com.
Most commented news this week
Hot Topics