PDA

Click to See Complete Forum and Search --> : Extracting corect website domain from string


wwwfilmfilercom
Aug 19th, 2007, 08:41 AM
I am adding links to my database via a form and would like to extract the website domain of the link and add it separately.

For instance if it was http://www.mydomain.com/i=sdfsdfsdfs&p=12313

I would like to save the entire string in one part of my database but also save mydomain.com in another part.

This is fairly straightword (I think I would use PREG but I'm sure I could find this solution via the internet) however the problem I have is with different types of links.

One link which I will use is affiliate links which come in the form of:

http://www.affiliate.net/id=2345345353&p=sdfiweoisdf&url=www.domain.com/id=23423424

The domain I want to extract will still be domain.com.

I need help on figuring out how to correctly extract a domain name address from a link. I guess one thing would be to start searching from the right hand side and look for www? However some urls may not have www. and also then there are issues over looking for .com or .co.uk since any extension could be used.

I'm confused as to what method I should use to correctly find a valid domain name - and also test it someway, such as with a dns check.

Any help would be appreciated;:thumb:

dclamp
Aug 19th, 2007, 05:30 PM
http://us.php.net/parse_url