I need to get some value from the url..
Like if the url was http://www.random.mysite.com/
Then I somehow want to get random
.
But this should work aswell if it use www
, http://
or https://
in-front of the url..
So how can this be done?
I tried this:
array_shift(explode(".",$_SERVER['HTTP_HOST']));
It works if the url is http://random.mysite.com/
, but if I put www
in-front, then I get www
returned instead?
Any ideas?
www
and if so, just repeat the process again with the rest of the exploded parts? Or you could use a regular expression.