GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   php question (https://gfy.com/showthread.php?t=917651)

campimp 07-23-2009 09:43 PM

php question
 
wanting to store sitename as a php variable.

if url was www somesitename .com

i want my page to pull "somesitename" and store as php variable, without the www or the .com

any thoughts?

FlexxAeon 07-23-2009 10:12 PM

where is it pulling 'somesitename' from? from the url it's located at?

Code:

<? $somesitename = $_SERVER['SERVER_NAME'];
$somesitename = str_replace( 'www.', '', $somesitename);
$somesitename = str_replace( '.com', '', $somesitename);
print $somesitename;
?>


cLin 07-23-2009 11:33 PM

Code:

$domain_strip = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']);
$domain = substr($domain_strip, 0, strpos($domain_strip, "."));

Grabs the domain name from website url. If that's what you want.

quantum-x 07-26-2009 03:50 AM

Quote:

Originally Posted by cLin (Post 16100259)
Code:

$domain_strip = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']);
$domain = substr($domain_strip, 0, strpos($domain_strip, "."));

Grabs the domain name from website url. If that's what you want.

Erk.
Try:
Code:

echo parse_url($u,PHP_URL_HOST);
Where $u has your URL string.

daniel_webcams 07-27-2009 05:33 AM

Quote:

Originally Posted by FlexxAeon (Post 16100054)
where is it pulling 'somesitename' from? from the url it's located at?

Code:

<? $somesitename = $_SERVER['SERVER_NAME'];
$somesitename = str_replace( 'www.', '', $somesitename);
$somesitename = str_replace( '.com', '', $somesitename);
print $somesitename;
?>


:thumbsup


All times are GMT -7. The time now is 09:17 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc