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. $ Aa: 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; PHP's unserialize 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 );?
???}?