加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

在php 中使用strip_tags的问题

发布时间:2020-12-13 16:03:17 所属栏目:PHP教程 来源:网络整理
导读:参见英文答案 strip_tags() … replace tags by space rather than deleting them10个 我已经使用strip_tags从文本中删除html标签. 例 h1title of article/h1div class="body"The content goes here....../divoutputs title of articleThe content goes here
参见英文答案 > strip_tags() … replace tags by space rather than deleting them10个
我已经使用strip_tags从文本中删除html标签.

<h1>title of article</h1><div class="body">The content goes here......</div>

outputs 

title of articleThe content goes here......

如果你看到输出标题和正文被加入(articleThe).如果标签被删除,我想插入一个空格.这可能吗.

我感谢任何帮助.

谢谢.

如果你想要的是添加一个开始标签直接跟随一个结束标签的空间,你可以这样做:
$html = preg_replace('/(</[^>]+?>)(<[^>/][^>]*?>)/','$1 $2',$html);
$html = strip_tags($html);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读