Home  >  Article  >  Backend Development  >  Introduction to filtering methods for special symbols in PHP strings_PHP Tutorial

Introduction to filtering methods for special symbols in PHP strings_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:24:471128browse

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);
}

www.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...
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