Re: Dissecting an email address

From: Date: Sun, 02 Nov 2003 14:55:23 +0000
Subject: Re: Dissecting an email address
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-168333@lists.php.net to get a copy of this message
Hi there, First, we have to realize that in an email there can be more than one period, but we only want to remove the top level domain. The solution? Remove the top level domain to begin with - You may be able to do that using explode() and the limit argument, but this was easier, in my opinion. <?php $email = 'me@hotmail.com'; //for example $email = substr($email, 0, strrpos($email, '.')); //remove the .com $email = explode('@', $email); //turn it into an array $email = $email[1]; //grab what's after the @ echo $email; //outputs 'hotmail' ?> Joachim Dave Carrera wrote:
Hi All, How do you split an email address sent via form post text field. I.e.: split me@hotmail.com into me@ hotmail .com It’s the domain bit I am interested in, not the username or tld. Any help is appreciated. Thank you in advance Yours Dave C --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.530 / Virus Database: 325 - Release Date: 22/10/2003


« previous php.general (#168333) next »