首页 > 解决方案 > 使用所有可能的属性从字符串中完全删除 img 标签

问题描述

我想使用字符串中的任何属性或样式完全删除 img 标签preg_replace

$content= "image to remove completely <img src="jem.jpg" style="height:162px; width:397px" />";

这是其中的东西。

我尝试使用preg_replace,但它没有用。

$content= "image to remove completely <img src="jem.jpg" style="height:162px; width:397px" />";

$content = preg_replace("/<img[^>]+\>/i", " ", $content ); 

预期输出:image to remove completely

标签: php

解决方案


推荐阅读