Jakes wrote:
I got this out the manual:

<?php
$email = '[EMAIL PROTECTED]';
$domain = strstr($email, '@');
print $domain; // prints @example.com
?>
how do I get the "user" ranther than "@example.com"Thanks


I would do something like this:


$email = "[EMAIL PROTECTED]";
if (preg_match("/^(.*)\@(.*)$/", $email, $matches)) {
        // $matches[0] contains the original $email
        $user = $matches[1];
        $domain = $matches[2];
}
echo $user . "<br />" . $domain;

Check out the manual for more info on preg_match():
http://www.php.net/manual/en/function.preg-match.php

--
Regards,
 Ben Ramsey
 http://benramsey.com
 http://www.phpcommunity.org/wiki/People/BenRamsey

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to