Search code examples
phpmysqlstripdoctrine-1.2

Replace " with \" with Doctrine 1.2


Here is my problem.

I get data from database using Doctrine 1.2 and put the data in a Textbox.

The data is 19" x 12" to put in the Textbox

Here is the result:

<input type="text" value="19" x 12"" />

I think I need to escape all the " with \"

My question is : How can I perform this automaticly without going into all my script and make a str_replace() ?

Thanks everyone.


Solution

  • I would just use htmlentities

    $string = htmlentities($text_with_quotes, ENT_QUOTES);
    echo '<input type="text" value="' . $string . '">';
    

    Should give you what you need.