PHP implementation filters out non-kanji characters to keep Chinese character only
This article mainly introduces the implementation of PHP to filter out non-Chinese characters only retain Chinese character, this article directly give implementation code, the need for friends can refer to the next
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$STR = "A 1b 2b< Chinese". Xxyy character "; Convert GB2312-UTF-8 $str = mb_convert_encoding ($str, ' UTF-8 ', ' GB2312 '); Preg_match_all ('/[\x{4e00}-\x{9fff}]+/u ', $str, $matches); $str = Join ("', $matches [0]); Convert UTF-8-GB2312 $str = mb_convert_encoding ($str, ' GB2312 ', ' UTF-8 '); Echo $str; Output Chinese Characters ?> |
http://www.bkjia.com/PHPjc/1011118.html www.bkjia.com true http://www.bkjia.com/PHPjc/1011118.html techarticle PHP Implementation to filter out non-Chinese characters only retain Chinese character this article mainly introduces the implementation of PHP to filter out non-Chinese characters only retain Chinese character, this article directly give implementation code, need of Friends ...