domain for email
Posted: Mon Aug 01, 2005 11:29 am
if I an email, something@aaa-bbb_ccc.com , how do I get only the domain part and excluding the first part up to the @ ?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$email_adress="something@something.de";
$explode_email=explode("@",$email_adress);
$domain=$explode_email[1];Code: Select all
function get_email_parts($address)
{
if (preg_match('/^([a-z0-9][\w\-\.]*[a-z0-9])@([a-z0-9][\w\-\.]*[a-z0-9])$/i', $address, $matches))
{
return array('local_part' => $matches[1], 'domain_part' => $matches[2]); //Return array
}
else
{
return false; //Doesn't fit the pattern
}
}EDIT | WTF happened to our tagsThis will do for now wrote: <?php
function get_email_parts($address)
{
if (preg_match('/^([a-z0-9][\w\-\.]*[a-z0-9])@([a-z0-9][\w\-\.]*[a-z0-9])$/i', $address, $matches))
{
return array('local_part' => $matches[1], 'domain_part' => $matches[2]); //Return array
}
else
{
return false; //Doesn't fit the pattern
}
}
?>