Hello All. I found this code on evil walrus... (I don't know how to post code here, so let's hope this works)
CODE:
function strip_domain($theURL) {
$theURL = str_replace("www.", "", $theURL);
$theURL = str_replace(substr($theURL,strpos($theURL,".")),"",$theURL);
return $theURL;
}
END OF CODE
Example of what code does:
echo strip_domain("www.evilwalrus.com");
Here is what I'd like to use the code for:
I have a form on my site for a visitor to add their domain. I would like to strip the www. and the .com, .net, .org from a domain if the visitor has typed their domain into the input box. Some visitors will read directions and see they are only supposed to type the middle, but others won't bother to read and may type in the entire URL and I don't want that.
I think the walrus code above does what I need, but how can I have it do that for my form. I am sure it is easy, but I am not the best php coder. When I get code to work how I want, it is normally lucky guess work or help from fine people like you...
Thanks a bunch!
Amanda