$this->domain = explode(".", $_SERVER['HTTP_HOST']); ..... function determineName() { if( sizeof($this->domain) == 3 ) { if( $this->domain[0] == "www" ) { return NULL; } else { return strtolower($this->domain[0]); } } elseif( sizeof($this->domain) == 4 ) { return strtolower($this->domain[1]); } }