View Single Post
Old 04-07-2005, 10:19 PM  
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
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.
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote