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.
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.
You can get rid of any char by using str_replace():
http://php.net/manual/en/function.str-replace.php
http://php.net/manual/en/function.str-replace.php
$char = "'";
$str = str_replace($char, '', $str);
You can also try to double the quotation by using the following code:
$str = str_replace("'", "''", $str);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
http://php.net/manual/en/function.stripslashes.php