working with a string..

General discussions related to php

Moderators: macek, egami, gesf

User avatar
leon
New php-forum User
New php-forum User
Posts: 36
Joined: Sat Aug 03, 2002 11:54 am

working with a string..

Postby leon » Fri Nov 01, 2002 2:12 pm

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

Jay

Postby Jay » Fri Nov 01, 2002 2:17 pm

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"

User avatar
leon
New php-forum User
New php-forum User
Posts: 36
Joined: Sat Aug 03, 2002 11:54 am

Postby leon » Fri Nov 01, 2002 2:23 pm

Jay wrote: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 !


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 2 guests

cron