用preg_replace 代替吧。ereg_replace 自5.3 起就废弃了。

解决方案 »

  1.   


    $content = '<img width="563" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'12\'})" inpost="1" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" file="data/attachment/forum/201405/21/134519pngfbniwifd61tky.jpg" zoomfile="data/attachment/forum/201405/21/134519pngfbniwifd61tky.jpg" src="data/attachment/forum/201405/21/134519pngfbniwifd61tky.jpg" aid="48110" id="aimg_48110" initialized="true">
    <div disautofocus="true" class="tip tip_4 aimg_tip" initialized="true"></div>';$value = "data/attachment/forum/201405/21/134519pngfbniwifd61tky.jpg";
    $find=str_replace('/','\/',preg_quote($value));
    $fileurl = "/uploads/image/20140902/20140902105805_83325.jpg";
    echo preg_replace('/<img([\w\W]+?)zoomfile="'.$find.'"\s*src=".+?"([^>]+?)>/i', "<img$1 src='".$fileurl."'$2/>", $content);/*
    <img width="563" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" inpost="1" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" file="data/attachment/forum/201405/21/134519pngfbniwifd61tky.jpg" src="/uploads/image/20140902/20140902105805_83325.jpg" aid="48110" id="aimg_48110" initialized="true">
    <div disautofocus="true" class="tip tip_4 aimg_tip" initialized="true"></div>
    */