本帖最后由 zhaixiaohu 于 2011-12-19 15:33:21 编辑

解决方案 »

  1.   


    $str = '<img style="margin: 0.0px;width: 750.0px;float: none;height: 157.0px;" border="0" src="http://www.xxx.com/imgextra/i4/222/1.jpg" width="750" height="157">';
    echo htmlspecialchars(preg_replace_callback('/src="(.*)"/isU', 'test', $str));function test($matches)
    {
        return 'src="' . base64_encode($matches[1]) . '"';
    }
    /**
    输出结果:
    <img style="margin: 0.0px;width: 750.0px;float: none;height: 157.0px;" border="0" src="aHR0cDovL3d3dy54eHguY29tL2ltZ2V4dHJhL2k0LzIyMi8xLmpwZw==" width="750" height="157">
    */