duanshan1511 2014-06-26 18:42
浏览 84
已采纳

使用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 ?

  • 写回答

3条回答 默认 最新

  • doumei2023 2014-06-26 18:48
    关注

    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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?