The source of crawling Chinese can be text, Web pages, as long as there is a Chinese place on the line, each part has a comment, which contains Chinese crawling and Chinese to heavy two parts.
<?php$str = "DDDDVVV (, Chinese.) Dfdsfds words, ah, ah. "; /convert GB2312 encoding to UTF-8 code//$str = mb_convert_encoding ($str, ' UTF-8 ', ' GB2312 ');//Regular Match preg_match_all ('/[\x{4e00}-\x{9fff }]+/u ', $str, $matches);//Connect the matched array to a string $str = Implode (", $matches [0]);//Chinese character de-weight $str = Str_split ($str, 3); $str = Array_ Unique ($STR); $str = implode ($STR);//convert UTF-8 code to GB2312 encoding $str = mb_convert_encoding ($str, ' GB2312 ', ' UTF-8 '); echo $str;?>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PHP Crawl Chinese characters