Home >Backend Development >PHP Tutorial >PHP str_replace 替换多个敏感词 【急,在线等】

PHP str_replace 替换多个敏感词 【急,在线等】

WBOY
WBOYOriginal
2016-06-23 14:13:291020browse

本帖最后由 u011123799 于 2013-06-19 12:42:46 编辑

PHP Palm Pre HTML


$html = HtmlReplace($body, 0); //过滤

echo $html;//输出内容是:
  <br>            //编译成HTML:<pre class="brush:php;toolbar:false">  <br>  <br>  <br> /*************以上为背景*************/  <br>  <br> $html = str_replace("<pre class="lang-js">","<pre class="brush:php;toolbar:false">",HtmlReplace($body, 0))  <br>  <br> 这样替换后可以正常输出了,但是问题来了!  <br>  <br> 我要替换多个标签,比如: <span>,<ul>,<li>...  <br>  <br> 这样一个一个写,太傻了!有什么办法可以一次性定义替换需要的内容?  <br>  <br> 如:  <br> <span> = <span>  <br> <ul> = <ul>  <br> <li> = <li>  <br>  <br> 新手  <br>  <br>  <br>  <br> <h2>回复讨论(解决方案)</h2> <p class="sougouAnswer">  echo htmlspecialchars_decode($html, ENT_QUOTES); </p> <p class="sougouAnswer">  #1是专门对付html标签的  <br> 另外还可以用数组和正则 </p>
</li>
</ul></span>
</li>
</ul></span>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn