Possible Duplicate:
PHP function to get the subdomain of a URL
Im looking for an efficient way to tell if a subdomain exists within a URL.
The domain name will always be fixed e.g. mydomin.com, however if a subdomain is not set, I need to redirect.
One thought I had is that if there is more than one period (.), a subdomain is set, but im not sure how to implement this.
Many thanks.
EDIT: Sorry for not being too clear. I do not have a current solution, but looking at other posts I can see several examples of how to get the subdomain e.g.
array_shift(explode(".",$_SERVER['HTTP_HOST']));
But i do not want the subdomain, just to check if one exists. The subdomain could be anything.