In this article, you will learn how to convert serialised data into original data. The unserialize() function in PHP converts serialized data back into actual data.
what is the syntax of the UNSERIALIZE() function in php?
unserialize(string, options);
Parameters | Details |
---|---|
string | Required. Specifies the serialized string |
options | Optional. Specifies options to be provided to the function, as an associative array. Can be either an array of class names which should be accepted, false to accept no classes, or true to accept all classes. True is default. |
examples of the UNSERIALIZE() function
Example 1. In this example, we convert serialized data back into actual data.
<?php
$data = serialize(array("Red", "Green", "Blue"));
echo $data . "<br>";
$test = unserialize($data);
var_dump($test);
?>