English garbled-php preg_match_all processing Chinese when garbled

Source: Internet
Author: User
PHP preg_match_all processing Chinese when garbled

The code is modified to Utf-8, but some of the matching results are garbled.

Reply content:

PHP preg_match_all processing Chinese when garbled

The code is modified to Utf-8, but some of the matching results are garbled.

If you need to support i18n, it is recommended that you use Mb_ereg_* series functions, see PHP Manual for details.

When we crawl the Remote Web page, it is likely due to coding problems garbled, must transcode

$file = file_get_contents ("Http://blog.xbmu.info");//remote Fetch preg_match_all ();//Extract information//select transcoding as required: $str 2 = iconv ("Utf-8", " Gb2312//ignore ", $str 2);//turn UTF GB2312$STR2 = Iconv (" gb2312 "," Utf-8//ignore ", $str 2);//Turn gb2312 to UTF
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.