Introduction to filtering methods for special symbols in PHP strings_PHP Tutorial

WBOY
Release: 2016-07-13 10:24:47
Original
1127 people have browsed it

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...
Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template