Sometimes we encounter the problem of filtering special characters in strings. This article provides a method for processing special strings. There may be some omissions. If readers find out, you can leave a message and let me know. Thank you.
Copy code The code is as follows:
function strFilter($str){
$str = str_replace(''' , '', $str);
$str = str_replace('·', '', $str);
$str = str_replace('~', '', $str);
$ str = str_replace('!', '', $str);
$str = str_replace('!', '', $str);
$str = str_replace('@', '', $ str);
$str = str_replace('#', '', $str);
$str = str_replace('$', '', $str);
$str = str_replace(' ¥', '', $str);
$str = str_replace('%', '', $str);
$str = str_replace('^', '', $str);
$str = str_replace('...', '', $str);
$str = str_replace('&', '', $str);
$str = str_replace('*', ' ', $str);
$str = str_replace('(', '', $str);
$str = str_replace(')', '', $str);
$str = str_replace('(', '', $str);
$str = str_replace(')', '', $str);
$str = str_replace('-', '', $str) ;
$str = str_replace('_', '', $str);
$str = str_replace('——', '', $str);
$str = str_replace('+ ', '', $str);
$str = str_replace('=', '', $str);
$str = str_replace('|', '', $str);
$str = str_replace('\', '', $str);
$str = str_replace('[', '', $str);
$str = str_replace(']', '', $str);
$str = str_replace('[', '', $str);
$str = str_replace('】', '', $str);
$str = str_replace( '{', '', $str);
$str = str_replace('}', '', $str);
$str = str_replace(';', '', $str);
$str = str_replace(';', '', $str);
$str = str_replace(':', '', $str);
$str = str_replace(':', ' ', $str);
$str = str_replace(''', '', $str);
$str = str_replace('"', '', $str);
$str = str_replace('"', '', $str);
$str = str_replace('"', '', $str);
$str = str_replace(',', '', $str) ;
$str = str_replace(',', '', $str);
$str = str_replace('<', '', $str);
$str = str_replace('> ;', '', $str);
$str = str_replace('《', '', $str);
$str = str_replace('》', '', $str);
$str = str_replace('.', '', $str);
$str = str_replace('. ', '', $str);
$str = str_replace('/', '', $str);
$str = str_replace(', ', '', $str);
$str = str_replace('?', '', $str);
$str = str_replace('?', '', $str);
return trim($str);
}
http://www.bkjia.com/PHPjc/825307.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825307.htmlTechArticleSometimes we encounter the problem of filtering special characters in strings. This article provides a method for processing special strings. There may be some omissions in the method. If readers find it, they can leave a message and tell me...