On Sat, Jan 20, 2001 at 09:10:45PM -0500, [EMAIL PROTECTED] wrote : 
> I have a form which users enter their email address, once submitted I need a 
> way to chop it up and put it in lowercase. So that if a user submits 
> [EMAIL PROTECTED] I want PHP to throw out Website4S and then make the rest 
> lowercase so I would get @aol.com
> 
> I know how to get the string to lowercase by using
> 
> $Email1=strtolower($Email);
> 
> My problem is how to get $Email and chop off anything up to the @ and because 
> people may enter different email providors I have no idea how to get around 
> it. Anyone have a suggestion I would really appreciate it.

        The key to your secret is called regular expression.

<?
        $email = "[EMAIL PROTECTED]";

        if( eregi( "^([^@]+)@([^@]+)$", $email, $match)) {
                $email_user   = $match[1];
                $email_domain = strtolower( $match[2]);
                echo "$email_user at $email_domain";
        } else
                echo "bad email";
?>

Note, this does not validate if the email is correct; if you need
this, take a look at php.net, some of the manual comments talk
about email validaten ( whereupon methinks Tom Christiansen email
verifier [written in perl] is still the best validator).

hope this helps

m.

-- 
Markus Fischer,  http://josefine.ben.tuwien.ac.at/~mfischer/
EMail:         [EMAIL PROTECTED]
PGP Public  Key: http://josefine.ben.tuwien.ac.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1  C2B5 D674 B445 C227 2BD0

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to