Well I lost the race as well, because I failed to account for .com.br, or .com.at, or any of those other rarely used ones. Bah... ___________________________________ Ryan Marrs Web Developer Sandler & Travis Trade Advisory Services, Inc. 248.474.7200 x 183 248.474.8500 (fax) www.strtrade.com -----Original Message----- From: 1LT John W. Holmes [mailto:holmes072000@charter.net] Sent: Friday, January 24, 2003 2:02 PM To: 1LT John W. Holmes; heilo; php-db@lists.php.net Subject: Re: function needed But what about www.domain.co.uk, you ask? Well, it'll fail with this. :) Just filter out the 'co.' like the other function that was posted and this will still work. ---John Holmes... ----- Original Message ----- From: "1LT John W. Holmes" <holmes072000@charter.net> To: "heilo" <grillen@abendstille.at>; <php-db@lists.php.net> Sent: Friday, January 24, 2003 1:58 PM Subject: Re: function needed > You could also use this: > > function getdomainname($name) > { > $parts = explode('.',$name); > return $parts[count($parts)-2]; > } > > which will always return the second to last section when divided up by the > periods. So it will return 'domain' for all of the following: > > www.domain.com > www.subdomain.domain.org > subdomain.domain.org > domain.museum > > ---John Holmes... > > ----- Original Message ----- > From: "heilo" <grillen@abendstille.at> > To: <php-db@lists.php.net> > Sent: Friday, January 24, 2003 1:27 PM > Subject: Re: function needed > > > > Hi! > > > > I hope I understood you right... I would use PCREs: > > > > <?php > > > > function getdomainname($string) > > { > > $pattern = '#(([[:alnum:]]+)(\.))?(.+)(\.)([[:alnum:]]+)#i'; > > $replace = '\\4'; > > return preg_replace($pattern, $replace, $string); > > } > > > > $var = $_SERVER['SERVER_NAME']; > > > > echo getdomainname($var); > > > > ?> > > > > > > .ma > > > > Shahar Tal <admin@websitefaq.com> wrote@24.01.2003 18:44 Uhr: > > > > > Hey > > > > > > I'm looking and wondering for a function, as i'm trying to do something, > and > > > here it is. > > > > > > I'm using the SSI call : > > > <!--#echo var="HTTP_HOST" -->. > > > to get the domain name I am on. this will output > > > > > > www.domain.com. > > > > > > I would like to use PHP in order to take this string, the output, and > cut > > > the "www." and the ".com" from it, so only the "domain" will remain. > > > ofcourse we can also have situations whith ".org" and ".net" and even > where > > > there's no "www." but the main thing I need is to remove whats > > > after the second dot and before the first dot, along with the dots. > > > > > > I don't mind writing all the posibilities to the function, ie, all the > > > possible extenstions that the function may need to cut, I just need it > to > > > take > > > the text from the SSI, and cut everything but the "domain" part, which > is > > > the address itself. > > > > > > what would be the best way to do it? > > > thank you!! > > > > > > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php