Jos*_*h R 11 html php strip-tags
我使用了strip_tags从文本中删除了html标签.
例
<h1>title of article</h1><div class="body">The content goes here......</div>
outputs
title of articleThe content goes here......
Run Code Online (Sandbox Code Playgroud)
如果你看到输出标题和正文已加入(articleThe).如果标签已被删除,我想插入一个空格.这可能吗.
我感谢任何帮助.
谢谢.
Bol*_*ock 21
如果您只想添加一个空格,其中开始标记直接跟在结束标记之后,您可以这样做:
$html = preg_replace('/(<\/[^>]+?>)(<[^>\/][^>]*?>)/', '$1 $2', $html);
$html = strip_tags($html);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8494 次 |
| 最近记录: |