Pages

How to Break Apart an Email Address


Snippet Name: Easy way to break apart an email address
Description: Probably the easiest way to break apart an email address is to use split() command to break into two parts. Every valid email address will have one '@' between the user name and the host or domain name.


<?
// the easy way to break an email address into the 
// user name and domain name
 
$email = "somename@domain.com";
 
$email_parts = split("@",$email);
 
echo $email_parts[0];
echo '<br />';
echo $email_parts[1];
 
// This will output "somename" and "domain.com"
?> 

No comments:

Post a Comment