--- Shahar Tal <[EMAIL PROTECTED]> wrote:
> 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.


You could use the str_replace() function. Put all the things you want
to eliminate into an array, $arr, and use the following:

$arr=array("www.",".com",".net",".org",".au",".uk"...);
$site=parse_url($_SERVER['HTTP_HOST']);
$domain=str_replace($arr,"",$site['host']);



=====
Mark Weinstock
[EMAIL PROTECTED]
***************************************
You can't demand something as a "right" unless you are willing to fight to death to 
defend everyone else's right to the same thing.
-Stolen from the now-defunct Randy's Random mailing list.
***************************************

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to