strip_tags() … replace tags by space rather than deleting them

前端 未结 10 988
日久生厌
日久生厌 2020-12-08 06:36

Do you know how to replace html tags with a space character using php?

If I display

strip_tags(\'

Foo

bar\');

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 07:19

    Something like this will work if you know that > won't be in any of your attributes.

    preg_replace('/<[^>]+>/', ' ', 'hello
    world');

提交回复
热议问题