serialize()
returns a string containing a byte-stream representation of any value that can be stored in PHP. unserialize()
can use this string to recreate the original variable values.
To serialize an object
serialize($object);
To Unserialize an object
unserialize($object)
Example
$array = array();
$array["a"] = "Foo";
$array["b"] = "Bar";
$array["c"] = "Baz";
$array["d"] = "Wom";
$serializedArray = serialize($array);
echo $serializedArray; //output: a:4:{s:1:"a";s:3:"Foo";s:1:"b";s:3:"Bar";s:1:"c";s:3:"Baz";s:1:"d";s:3:"Wom";}