使用str_replace替换img src无效

Hi I'm trying to modify the src of a image that I uploaded by ckfinder and I want a full path I see other answers here but I dont know why my code doesn't work ,look at it please

$html = '<p> <img alt="" src="/deconsultas/javascript/ckfinder/files/images/xxx.jpg"/></p>';
$dato = str_replace("src=&quot/deconsultas/javascript","a",$html);
echo $dato;

Where is the error please ?

I think you need this.

$html = '<p> <img alt="" src="/deconsultas/javascript/ckfinder/files/images/xxx.jpg"/></p>';
$dato = preg_replace("/\/deconsultas\/javascript/","a",$html);
echo $dato;

just change str_replace("src=&quot/deconsultas/javascript","a",$html) to str_replace("src=\"/deconsultas/javascript","a",$html)

Escape quote with slash

use

\"

instead of

&quot