Home > Article > Backend Development > Example of php serialized array
2, PHP serialization Array usage: It mainly handles array transfer and array storage operations. For example, there is an array that needs to be passed to the next page. If you do not want to use seesion/cookie, you can use the above function to serialize and pass it, and then restore it. For example, if you are making a website directory program, there will be a rating, which is divided into good reviews, medium reviews, and bad reviews. Then, the database has only one field designed for this function, and the type is long character. Combine three comments into an array:
and convert it with the serialize function: a:3:{s:1:"a";i:0;s:1:"b";i:0;s :1:"c";i:0;}, then the database exists. Don't forget to use the unserialize function to convert it into an array when taking it out. Serialization of arrays is often used. It is recommended that everyone has a firm grasp of it, especially the usage of the serialize and unserialize functions, but also a flexible grasp. |