Re: Getting the first part out of a string

From: Date: Fri, 04 May 2001 09:14:07 +0000
Subject: Re: Getting the first part out of a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51395@lists.php.net to get a copy of this message
$pos = strpos($hostdomain, '.'); if ($pos === false) { /*no point found */} else $str = substr($hostdomain,0, $pos); or much better: $parts = explode('.', $hostdomain); and you get all parts of $domain name. from $hostdomain = "www.behsci.sote.hu" $parts = array('www', 'behsci', 'sote', 'hu'); ----- Original Message ----- From: "Richard Kurth" <rkurth@pacifier.com> To: <php-general@lists.php.net> Sent: 2001. május 4. 02:44 Subject: [PHP] Getting the first part out of a string > I know how to get last part of a string out of a string > But how do I get the first part before the needle On the example > below I just what domain > > $hostdomain= domain.com > > $host = substr (strrchr ($hostdomain, "."), 1); > echo $host; com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#51395) next »