Serialize --------- format the array into an ordered string
Unserialize ----- restore an array to an array
PHP serialization array test instance:
$ Test = array ("a" => 0, "B" => 0, "c" => 0 );
$ Test2 = '';
$ Test2 = serialize ($ test );
Echo $ test2;
Echo "Print_r (unserialize ($ test2 ));
PHP serialization array usage:
In my personal experience, I mainly deal with array transfer and array inventory operations.
For example, I have an array that needs to be passed to the next page. If you do not want to use seesion/cookie, you can use this function to pass and restore it.
For example, when I make a website directory, there is a score, which can be divided into high praise, medium rating, and poor rating. Then, my database designs one field for this function, and the type is long standby type. Combine the three comments into an array:
Array (
'A' => 0, // 0
'B' => 0, // 0
'C' => 0 // 0 negative ratings
)
After converting it with the serialize function, it is: a: 3: {s: 1: "a"; I: 0; s: 1: "B"; I: 0; s: 1: "c"; I: 0;}, and then the database exists. Do not forget to use the unserialize function to convert it to an array.
The above is the correct method for using PHP serialized arrays.