php 利用正则表达式清理字符串删除、替换不需要字符

前端之家收集整理的这篇文章主要介绍了php 利用正则表达式清理字符串删除、替换不需要字符前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
一个简单的正则表达式清理不需要的字符,PHP从字符串删除、替换不需要的字符,感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编来看看吧。
经测试代码如下:

/**
 * 从字符串删除、替换不需要的字符
 *
 * @param 
 * @author 编程之家 jb51.cc jb51.cc
 **/
function setDescriptionString($inputString=""){
     $replacedWords = array("…","‘","ó","<ul>","<li>","–","…"," ",""","&","“","”","<span>","</span>","<p>","</p>","/",":","<",">","<strong>","</strong>","<b>","</b>","<i>","</i>","span","strong","class","+","-","=","'","’");
     $filteredString = str_replace($replacedWords,"",$inputString).".";
     return $filteredString;
}


/***   代码来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/529149.html

猜你在找的PHP相关文章