...

View Full Version : php split



simjay
04-27-2006, 05:19 AM
Hey Guys

I would like to split an email address with PHP, for example.

mail@anemailaddress.com
james@anemailaddress.com
chris@anemailaddress.com

With the PHP I want to get a list:
mail
james
chris

I would like to get rid of the email extention.



<?

echo "$namebefore@";

?>

Many thanks

Brandoe85
04-27-2006, 05:27 AM
You can use explode (http://us2.php.net/explode) or a regex.

Good luck;

chump2877
04-27-2006, 05:30 AM
Use the explode() function:


$email = 'mail@anemailaddress.com';
$email_parts = explode('@',$email);
echo $email_parts[0];

MRMAN
04-27-2006, 10:16 AM
if you use the list function then you won't have to deal with the array.
like this


$email = 'mail@anemailaddress.com';
list($name,$extention) = explode('@',$email);
print $name;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum