Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 04-07-2005, 09:38 PM   #1
4Pics
Confirmed User
 
Industry Role:
Join Date: Dec 2001
Posts: 7,952
Php help needed...

Is there a better way to get this other then doing it in 2 steps?

$site = preg_replace ('#www.#is', '', $_SERVER['HTTP_HOST']);
$site = preg_replace ('#.com#is', '', $site);

I want just the parts inbetween www and the last . where its .com/.net etc.

Thanks
4Pics is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-07-2005, 10:19 PM   #2
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
Old 04-07-2005, 10:24 PM   #3
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
a bit of mix up in the above post for one liner, heres the correct one:

$site = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1, strpos($_SERVER['HTTP_HOST'], '.', (strpos($_SERVER['HTTP_HOST'], '.')+1)+1)-strpos($_SERVER['HTTP_HOST'], '.')+1);

or

$domain = $_SERVER['HTTP_HOST'];
$site = substr($domain, strpos($domain, '.')+1, strpos($domain, '.', (strpos($domain, '.')+1)+1)-strpos($domain, '.')+1);
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-07-2005, 11:10 PM   #4
Due
Confirmed User
 
Due's Avatar
 
Industry Role:
Join Date: Mar 2001
Location: Murrieta, CA
Posts: 3,620
Are you looking for _SERVER["SERVER_NAME"] ??
__________________
I buy plugs
Skype: Due_Global
/Due
Due is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-07-2005, 11:16 PM   #5
Due
Confirmed User
 
Due's Avatar
 
Industry Role:
Join Date: Mar 2001
Location: Murrieta, CA
Posts: 3,620
Ohhh you wanted it without .com/.net or whatever
$bla=$_SERVER["SERVER_NAME"];
$pieces = explode(".", $bla);
echo "domain: $pieces[0]<br>extension $pieces[1]";
__________________
I buy plugs
Skype: Due_Global
/Due
Due is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-08-2005, 12:04 AM   #6
4Pics
Confirmed User
 
Industry Role:
Join Date: Dec 2001
Posts: 7,952
thanks

That gave me more then 1 way to do it.
4Pics is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-08-2005, 12:23 AM   #7
BrettJ
ol' timer
 
Industry Role:
Join Date: Jan 2001
Location: Seattle WA
Posts: 4,715
you guys are dorks ;)
BrettJ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-08-2005, 12:28 AM   #8
AgentCash
Confirmed User
 
Join Date: Feb 2002
Posts: 720
preg_match('/(?:www\.)*(.*?)\./', $_SERVER['HTTP_HOST'], $sitearr);
$site = $sitearr[1];
AgentCash is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-08-2005, 01:39 AM   #9
AlCapone
Confirmed User
 
AlCapone's Avatar
 
Join Date: Sep 2003
Posts: 708
__________________
"You can get more with a kind word and a gun than you can with a kind word alone.”
AlCapone is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.