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 = '[EMAIL PROTECTED]'; //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 [EMAIL PROTECTED] 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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php