Link to home
Start Free TrialLog in
Avatar of steva
steva

asked on

Getting rid of escaped ' in email

I have a form with a textarea input to let the customer enter comments. The PHP code  that processes the form puts the string from the textarea into the body of an email and sends it to me.

The problem is that if the client enters an apostrophe ( ' ), as in "Here's a new order"  it shows up in the email I get as " Here\'s a new order."

Does anyone know how I can get rid of the \  in the email?

Thanks for any help.
Avatar of minjosefa
minjosefa
Flag of undefined image

Avatar of Brad Brett
You can get rid of any char by using str_replace():

http://php.net/manual/en/function.str-replace.php
$char = "'";
$str = str_replace($char, '', $str);

Open in new window

You can also try to double the quotation by using the following code:
$str = str_replace("'", "''", $str);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of steva
steva

ASKER

Thanks