The serialize() function is used to serialize an object or array and returns a string.
After the serialize() function serializes an object, it can be easily passed to other places that need it, and its type and structure will not change.
If you want to convert a serialized string back into a PHP value, use unserialize()。
PHP version requirements: PHP 4, PHP 5, PHP 7
Grammar
string serialize ( mixed $value )
Parameter description:
$value: The object or array to be serialized.
return value
Returns a string.
Example
<?php
$sites = array('Google', 'Runoob', 'Facebook');
$serialized_data = serialize($sites);
echo $serialized_data . PHP_EOL;
?>The output is:
a:3:{i:0;s:6:"Google";i:1;s:6:"Runoob";i:2;s:8:"Facebook";}