Results 1 to 2 of 2

Thread: Extracting corect website domain from string

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    From the UK
    Posts
    422

    Extracting corect website domain from string

    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=23453453...om/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;

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Extracting corect website domain from string

    My usual boring signature: Something

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width