How to extract username from an e-mail address string
by Gabriel on 05/09/08 at 12:42 pm
Greetings! Subscribe to my RSS feed or get my latest post directly in your mailbox. Thanks for visiting!
If you need to extract the username from an e-mail address string then this snippet can help you. For instance, you can use this function inside a loop, while selecting emails from a database.
<?php
function getUsernameFromEmail($email)
{
$find = '@';
$pos = strpos($email, $find);
$username = substr($email, 0, $pos);
return $username;
}
$email = 'thecoder@domain.com';
$username = getUsernameFromEmail($email);
echo $username; // thecoder
?>
Be notified when we have new posts by subscribing to
BitRepository RSS Feed.
BitRepository RSS Feed.Please spread the word! |
|
Leave a Comment