Im getting the URL using:
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
This returns something like:
How can I select 'me' only?
Im getting the URL using:
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
This returns something like:
How can I select 'me' only?
Use parse_url, get the host of the URL and split it by dots. Then you can retrieve your desired subdomain easily.
Edit: Answered too fast, this is not the real answer to your problem, you could do that this way but i wouldn't do it. If you want the requested subdomain you can use something like that:
$hostParts = explode('.', $_SERVER['HTTP_HOST'])
print $hostParts[0];
Note that this example does not include error handling. (i.e.: $_SERVER['HTTP_HOST'] might be empty)
$uriParts = explode('.',$_SERVER['SERVER_NAME']);
$subDomain = $uriParts[0];