php替換中文字符


$words = ["我", "你", "他", "她"];//過濾庫
$sentence = "我和你一起去他家找她";//待過濾的句子
foreach($words as $word)//遍歷過濾庫的詞
{
$len = strlen($word);//獲取過濾詞的長度
$pos = strpos($sentence,$word);//尋找過濾詞的位置
$sentence = substr_replace($sentence,'', $pos, $len); 
}
echo $sentence;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM