Home  >  Article  >  Backend Development  >  Serialization of arrays

Serialization of arrays

WBOY
WBOYOriginal
2016-08-08 09:26:091946browse

Array serialization is to convert the array data into a string for transmission and database storage. The corresponding deserialization is to convert the string data into array data.
The function corresponding to serialization is serialize(), and the function corresponding to deserialization is: unserialize().
The data after serialization of the former can be stored in a certain field of the database, and then processed through deserialization when used.
Here is a simple example:
$arr = array('Zhang San','Li Si');
$str = serialize($arr);
echo $str."
";
$new_arr = unserialize($str);
print_r($new_arr);

?>

Run result:


The above has introduced the serialization of arrays, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Return to WordPressNext article:Return to WordPress