note 58610 added to function.substr
| From: | luciomonter at libero dot it | Date: | Wed, 09 Nov 2005 15:03:45 +0000 |
| Subject: | note 58610 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98333@lists.php.net to get a copy of this message | ||
As I didn't find it while I was looking for it....
A simple way to extract username from a mail address :
pincopallino@hotmail.com -> pincopallino
function EXTRACT_USERNAME($address)
{
$pos = strpos($address, "@");
if ($pos === false)
{
echo " @ not found in : $address, seems not to be an e-mail address <br/>\n";
}
/*else
{
echo " @ found in $address at column $pos <br/>\n";
}*/
$username = substr("$address", 0, $pos);
return($username);
}
Hope I saved a 10 minutes work to someone !
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58610
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58610&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58610&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58610&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58610&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58610&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58610&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58610&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58610&report=yes
Search -- http://master.php.net/manage/user-notes.php