I am trying to modify a login screen to prevent people from adding their e-mail to the end of their login name. Basically, I want
cjswanson1355@hotmail.com
to be filtered and return
cjswanson1355
But I am having difficulty in finding exactly what function I am supposed to be using.
Simple replacement question
Moderator: General Moderators
-
cjswanson1355
- Forum Newbie
- Posts: 10
- Joined: Wed Nov 05, 2008 3:13 pm
Re: Simple replacement question
You can filter out a @ (and everything after) with substr and strcspn:
Code: Select all
$name = "cjswanson1355@hotmail.com";
echo substr($name, 0, strcspn($name, "@"));- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Simple replacement question
How about something like:
Code: Select all
function Filter_Email($email)
{
return substr($email, 0, strpos($email, '@'));
}
echo Filter_Email('jobby@toilet.net');
// Output:
// jobbyRe: Simple replacement question
Same thing, different function 
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Simple replacement question
Yeah, wouldn't have bothered except it didn't look like anyone had answered when I started my reply 