Reply to Re: remove last part of email address

Your name:

Reply:


Posted by David Gillen on 01/04/07 14:49

schwooba@gmail.com said:
> Is there a simple way to remove the last part of an email address using
> PHP. I want to remove the @ symbol and everything to the right of it.
> Any ideas?
>
> Example:
>
> thomas@xyz.com
>
> should be:
>
Use substr[1] to get from the start of the string to the point you want.
The point you want is @ , indentified by strpos[2].

[1] http://www.php.net/substr
[2] http://www.php.net/strpos

So
$name = substr($email, 0, strpos($email, '@'));
should get you fairly close to what you want. Might need to increment or
decrement the result of strpos, I can't recall, to avoid getting the @ symbol
or get the last char of the name.

Or you could
$array = explode('@', $email); // Ka-BOOM!
$name = $array[0];

D.
--

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация