Idea: 1. encode the string with urlencode. 2. use regular expressions to search for statements ending with transcoding punctuation. 3. urldecode decoding data blog.ddian.cn? Post833 ideas:
1. encode the string with urlencode.
2. use regular expressions to search for statements ending with transcoding punctuation.
3. urldecode decoding data
Http://blog.ddian.cn /? Posting = 833
1. PHP code
Echo urlencode (',-.-? -! -;-,-. -? -! -;-...... '). PHP_EOL; $ str = "Open Source China, open source china. open source China? Open source China! Open source China; open source China. Open source China? Open source China! Open source China; open source China... "; echo $ str; $ str = urlencode ($ str); preg_match_all ('/(.*?) (\. {3, 6} | % 2C | \. | % 3F | % 21 | % 3B | % EF % BC % 8C | % E3 % 80% 82 | % EF % BC % 9F | % EF % BC % 81 | % EF % BC % 9B) /', $ str, $ matchs); foreach ($ matchs [0] as $ v) {$ newArr [] = urldecode ($ v);} var_dump ($ newArr );
The above is the PHP Chinese and English sentence without garbled content. For more information, please follow the PHP Chinese network (www.php1.cn )!