this will remove the www plus the top level domain
<?php
$site = 'www.somesite.home.com';
$site = str_replace('www.', '', $site);
$site = explode('.', $site);
$site = array_pop($site);
$site = implode('.', $site);
// somesite.home
?>
this will remove the first host and the top level domain.
<?php
$site = 'www.somesite.home.com';
$site = explode('.', $site);
$site = array_pop($site);
$site = array_shift($site);
$site = implode('.', $site);
// somesite.home
?>
--
Chris Lee
[EMAIL PROTECTED]
"Richard Kurth" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
I am trying to figure out how to pull data out of a string. This is
driving me crazy. I figure an if statement of some sort would work but
I'm not sure how to structure it.
I know how to get what I want if it is just
$fullhostname = "www.domain.net";
$exp = explode(".", $fullhostname);
$host = $exp[0];
$domain = $exp[1];
$tld = $exp[2];
But what if it looks like this
$fullhostname = "www.mysit.dom.net";
I need
$host= www
$domain = mysit.dom
$tld = net
or this
$fullhostname = "mysite.domain.net";
$host =
$domain = mysite.domain
$tld = net
Or even worse this
$fullhostname = "mysit.dom.net";
$host =
$domain = mysit.dom
$tld = net
Best regards,
Richard
mailto:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]