if (preg_match('/^([^.]+)\.lofak\.ru/i', $_SERVER['HTTP_HOST'], $domain)); $subdomain = $domain[1]; echo $subdomain;