working with a string..

A

Anonymous

Guest
I have a problem managing a string ..

I have

$email = "test@foo.bar";

and I need to echo only "test" (excluding @foo.bar ) .

Any idea to do that :roll: ? Thank you
 
A variety of methods are open to you. If you just want the user name from an email you can use:
list($user,$domain) = explode("@",$email);

$user will now be "test"
 
Jay said:
A variety of methods are open to you. If you just want the user name from an email you can use:
list($user,$domain) = explode("@",$email);

$user will now be "test"

:p , Thanks Jay , you are a php guru I am loving php and this forum too !
 
Back
Top