Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to replace quotation marks with \"

im trying to echo mediaplayer embed code with IF statement. is there any way to replace all quotation marks (") with (\")'s ?

thank you..

like image 736
Ali Demirci Avatar asked Dec 12 '22 22:12

Ali Demirci


2 Answers

As comments and other answers indicate your question may not be quite explicit enough. Taking it at face value, if you just want to replace double quotes (") you should use str_replace()

str_replace('"', '\"', $string);
like image 85
Yacoby Avatar answered Dec 31 '22 02:12

Yacoby


addslashes will do the trick.

It will return a new string with the all the quotes ( ' and " ) with their escaped counterparts.

like image 22
Jacob Relkin Avatar answered Dec 31 '22 02:12

Jacob Relkin