Remove character before/after symbol

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spyworld
Forum Newbie
Posts: 1
Joined: Thu Nov 27, 2008 7:11 am

Remove character before/after symbol

Post by spyworld »

I would like to remove a symbol after another symbol.

Example:
email#@gmail.com change to email@gmail.com
email+^@hotmail.com change to email@hotmail.com

Remove all the symbol before "@"

Example:
*me^personal*email@yahoo.com change to email@yahoo.com

If the email address is all symbol before "@", delete from database.
*^$!@yahoo.com direct delete from database.

How to write the script? feel like very complicated.
ScOrPi
Forum Commoner
Posts: 44
Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ

Re: Remove character before/after symbol

Post by ScOrPi »

use

preg_replace function

like this

Code: Select all

$mail = "example$";
$at_company = "@yahoo.com";
$mail_with_out_sym = preg_replace("symblos here",$mail);
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Remove character before/after symbol

Post by shawngoldw »

This sounds like an odd thing to be trying to do. If I may ask, why are you trying to do this? Are you trying to validate the email address?

Shawn
Post Reply