I'm trying to isolate the domain name from the HTTP_HOST variable
ie/ HTTP_HOST = www.domain1.com (I want to isolate "domain1" without the "www" or ".com")
Can anyone help with some suggestions? I imagine I could use reg expressions somehow, but I'm unfamiliar with these.
Thanks in advance
it may be easier to use substr() by removing the first four characters and then removing the last four.
like:
$host = "www.domain.com";
$newhost = substr($host, 4); $newhost = substr($newhost, 0, -4);
echo $newhost;
Thanks for the post....
The only problem I see with that is in the event that someone types in "domain.com" (without the "www"). In this event, substr() would chop off part of the name (leaving "in" instead of "domain")
check out the variable $SERVER_NAME, i think its just the domain part.
Use the parse_url() function in PHP. Very very simple and will do exactly what you need. It returns an array of different parts of the url.
Example: $url=parse_url(http://www.php.net/download-php.php3?csel=br);
$url[scheme] = http $url[host] = www.php.net $url[path] = /download-php.php3 $url[query] = csel=br
Cheers.
Ron,
Thanks for your reply.. This still leaves me with the "www" and the ".com" part of the name... I'm trying to remove those and just leave what's between the "WWW" and the ".com" part of the host name. For example: www.abc.com should = I want to see just "abc".
Any suggestions?
Thanks