KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
PHP's parse_url() has a host field, which includes the full host. I'm looking for the most reliable (and least costly) way to only return the domain and TLD. Given the examples: http://www.google.com/foo , parse_url() returns www.google.com for host http://www.google.co.uk/foo , parse_url() returns www.google.co.uk for host I am looking for only google.com or google.co.uk . I have contemplated a table of valid TLD's/suffixes and only allowing those and one word. Would you do it any other way? Does anyone know of a pre-canned valid REGEX for this sort of thing?
Tags (comma-separated)
Save Edits
Cancel