Re: function needed
| From: | Windi of NylonCoffee | Date: | Sat, 25 Jan 2003 01:53:32 +0000 |
| Subject: | Re: function needed | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25121@lists.php.net to get a copy of this message | ||
Hi! This shouid be good:
<?php
function getdomainname($name)
{
if(substr($name,0,4)=='www.') $name = substr($name,4,(strlen($name)-4));
return substr($name,0,strrpos($name,"."));
}
echo getdomainname('www.nyloncoffee.interpc.pl');
?>
short, nice and it's work good :)
----- Original Message -----
From: "Shahar Tal" <admin@websitefaq.com>
Newsgroups: php.db
To: <php-db@lists.php.net>
Sent: Friday, January 24, 2003 6:44 PM
Subject: function needed
> 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!!
>
>