💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
# 去除文本中的html、xml的标签 strip\_tags—从字符串中去除 HTML 和 PHP 标记 > **strip\_tags**(string`$str`\[,string`$allowable_tags`\] ) :string ``` <pre class="calibre10">``` $text <span class="token1">=</span> <span class="token2">'<p>文本</p><!-- 注释 --> <a href="#fragment"><img src="#">哈哈</a>'</span><span class="token3">;</span> <span class="token">// 允许 <p> 和 <a></span> echo <span class="token4">strip_tags</span><span class="token3">(</span>$text<span class="token3">,</span> <span class="token2">'<p><a>'</span><span class="token3">)</span><span class="token3">;</span> 输出: <span class="token1"><</span>p<span class="token1">></span>文本<span class="token1"><</span><span class="token1">/</span>p<span class="token1">></span> <span class="token1"><</span>a href<span class="token1">=</span><span class="token2">"#fragment"</span><span class="token1">></span>哈哈<span class="token1"><</span><span class="token1">/</span>a<span class="token1">></span> ``` ``` > 不完整或者破损标签将导致更多的数据被删除