How to extract domain name from an e-mail address string
by Gabriel on 05/09/08 at 12:02 pm
Greetings! Subscribe to my RSS feed or get my latest post directly in your mailbox. Thanks for visiting!
If, for any reason, you need to extract the domain from an e-mail address (or from multiple e-mail address that are in a database) then you can use this function:
<?php
function getDomainFromEmail($email)
{
// Get the data after the @ sign
$domain = substr(strrchr($email, "@"), 1);
return $domain;
}
// Example
$email = 'the_username_here@yahoo.com';
$domain = getDomainFromEmail($email);
echo $domain; // yahoo.com
?>
Be notified when we have new posts by subscribing to
BitRepository RSS Feed.
BitRepository RSS Feed.Please spread the word! |
|
Leave a Comment