1 header("Content-type:text/html;charset=utf-8"); 2 $aaa = "http://upfile.cuepa.cn/data/paper/2020/09/23/20200923163055_898895_small.jpg"; 3 $str = 'sf你好 <img alt="" title="" hspace="0" src="http://upfile.cuepa.cn/data/paper/2020/09/23/20200923163055_898895_small.jpg" align="baseline" border="0" title=""/><img alt="" title="" hspace="0" src="http://upfile.cuepa.cn/data/paper/2020/09/23/20200923163055_898895_small.jpg" align="baseline" border="0" title=""/>我在这里啊'; 4 echo '这是原始内容:<br/>'; 5 echo $str.'<br/>'; 6 echo '<hr />'; 7 //过滤图片 8 $str = preg_replace('~<[img|IMG](.*?)src="'.$aaa.'"(.*?)>~s','',$str); 9 echo '这是过滤后的内容:<br/>'; 10 echo $str;