$subdomain = explode('.', $_SERVER['HTTP_HOST'])[0];
$host = $_SERVER['HTTP_HOST']; preg_match("/[^./]+.[^./]+$/", $host, $matches); echo "domain name is: {$matches[0]} ";