How to use php preg_replace to replace HTML tags

前端 未结 3 1448
执念已碎
执念已碎 2020-12-17 04:11

I\'d like to change

 with  and 
with .

I\'m having problem with t

3条回答
  •  太阳男子
    2020-12-17 04:17

    You probably need to escape the /s with \s, or use a different delimiter for the expression.

    Instead, though, how about using str_replace?

     and 
    will be easy to match as they're not likely to contain any classnames or other attributes.

    $text=str_replace('
    ','',$text);
    $text=str_replace('
    ','',$text);

提交回复
热议问题