Re: strstr
| From: | Richard Davey | Date: | Fri, 27 Feb 2004 14:02:46 +0000 |
| Subject: | Re: strstr | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-179002@lists.php.net to get a copy of this message | ||
Hello Jakes,
Friday, February 27, 2004, 1:55:40 PM, you wrote:
J> I got this out the manual:
J> <?php
J> $email = 'user@example.com';
J> $domain = strstr($email, '@');
J> print $domain; // prints @example.com
?>>
J> how do I get the "user" ranther than "@example.com"Thanks
Use strpos() to locate the character (or string) you want and substr()
it. Something like:
$search = "@";
$email = "user@domain.com";
$user = substr($email, 0, strpos($search));
--
Best regards,
Richard Davey
http://www.phpcommunity.org/wiki/296.html