Disable magic_quotes in your php config, then edit all your text where this error occurs to correct.
Need a remove \" from image src in php
Pregunta
I need to replace \" from image src.
I have one form and i use the FCK editor for Details and when i upload image and submit a form then after i get below value in post
<img scr="\"http://test.in/public/admin/uploadfiles/Lighthouse(2).jpg\"">
So i need to remove \" from starting and \" from end
so its display properly to me.
I also try ltrim() and strreplace()
but when i put some other things then it replace each place so i need to replace it only in img scr must start and end \" only
Any why to do this. I think this is possible using Regular expression but i have not enough knowledge for it.
Please suggest me any idea.
Solución
Otros consejos
Change the php.ini setting magic_quotes_gpc = Off
. If you can't do that, use ini_set
in the php code itself. If you can't do that, use stripslashes
on the $_POST
value you are getting.
I would agree with what @Lee is saying however if you need to do it via a regular expression. This should do it.
<?php
$pattern = '/\\\"/';
$replacement = '';
$subject = '<img scr="\"http://test.in/public/admin/uploadfiles/Lighthouse(2).jpg\"">';
$result = preg_replace ($pattern, $replacement, $subject);
?>
using regexps, you could do it with the following: to remove the first \", use
preg_replace('/<img scr=\"\\\/', '<img scr=', $your_string);
and then replace the second part with
preg_replace('/\\\\"\">/', '">', $your_string);