one line:
$site = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1, strpos($_SERVER['HTTP_HOST'], '.', $a+1)-strpos($_SERVER['HTTP_HOST'], '.')+1);
the same as above but more readable:
Code:
$a = strpos($_SERVER['HTTP_HOST'], '.')+1;
$b = strpos($_SERVER['HTTP_HOST'], '.', $a+1);
$site = substr($_SERVER['HTTP_HOST'], $a, $b-$a);
basically this code finds first & second periods and copies anything between them to the new variable.