Removing \ from Saved Data

I am saving some text to a setting field for use in an email template.

So the text that is being put into the textarea to save looks like this…

Read More
<p>some text <a href="http://www.website.com">[HERE]</a></p>

and after saving it looks like this….

<p>some text <a href="http://www.website.com">[HERE]</a></p>

So what do I need to do to make it remove the \ when I need to work with this data?


UPDATE

I am saving the option/setting with this…

update_option('contact_record_client_template', $post_client_template);

So when I retrieve it with

$client_template = get_option('contact_record_client_template');

I just need to remove the ///‘s

If I run stripslashes() on it, it removes 2 of the 3 /‘s so it still leaves 1.

I also tried using str_replace( '///', '', $value ); but it just seems to add more or do nothing

Related posts

1 comment

  1. You can change the " signs to &quot; automatically using PHP’s htmlspecialchars() prior to your update_option() call:

    $post_client_template = htmlspecialchars( $post_client_template );
    update_option( 'contact_record_client_template', $post_client_template);
    

    If you need to change ' characters as well, use this:

    $post_client_template = htmlspecialchars( $post_client_template, ENT_QUOTES );
    update_option( 'contact_record_client_template', $post_client_template);
    

Comments are closed.