pulling data out of a string

From: Date: Mon, 14 May 2001 21:37:52 +0000
Subject: pulling data out of a string
Groups: php.general 
Request: Send a blank email to php-general+get-52746@lists.php.net to get a copy of this message
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:rkurth@pacifier.com

« previous php.general (#52746) next »