Re: Getting the first part out of a string
| From: | Hrishi | Date: | Fri, 04 May 2001 07:44:01 +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-51382@lists.php.net to get a copy of this message | ||
Richard Kurth wrote:
> 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);
strrchr (two r) finds the first occurence from the end of the string
strchr (one r) finds the first occurence from the beginning of the string
> echo $host; com
>
>
>