PHP unserialize back false

Source: Internet
Author: User
PHP's unserialize returns false. The problem is described as follows: the data after the array is serialized, but it cannot be deserialized after it is obtained. $ A = 'A: 2: {I: 1; a: 5: {s: 8: "pic_sort"; I: 2; s: 9: "pic_check"; B: 1; s: 10: "The unserialize of pic PHP returns false

Problem Description: The following is the data after the array is serialized. but after the data is obtained, The deserialization fails. $ A = 'A: 2: {I: 1; a: 5: {s: 8: "pic_sort"; I: 2; s: 9: "pic_check"; B: 1; s: 10: "pic_select"; I: 56; s: 8: "pic_path"; s: 1: "ergregerg"; s: 8: "pic_link"; s: 2: "wesaddasd";} I: 2; a: 5: {s: 8: "pic_sort"; I: 2; s: 9: "pic_check"; B: 0; s: 10: "pic_select"; I: 57; s: 8: "pic_path"; s: 10: "4444"; s: 8: "pic_link"; s: 14: "http://fafa.com" ;}}'; print_r (unserialize ($ ));
Cause: The encoding retrieved from the database is inconsistent with the page encoding.
Solution: You can customize the following function calls ??? Print_r (mb_unserialize ($ ));??? Function mb_unserialize ($ serial_str ){?????? $ Out = preg_replace ('! S :( \ d + ):"(.*?) ";! Se ', "'s:'. strlen ('$ 2').': \" $2 \ "; '", $ serial_str );?????? Return unserialize ($ out );????}?

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.