Forum Moderators: coopster
preg_match('/[^.]+\.[^.]+$/', $host, $matches);
echo "domain name is: {$matches[0]}\n";
The code above will return the correct domain is the user input is something like http://www.example.com
But if the input is http://www.example.co.uk it will return co.uk
also it will accept an input like abc@.com (will return abc@.com as domain)
Anyone who has a better solution?
[1][edited by: Gian04 at 7:42 am (utc) on June 11, 2007]