PHP: unserialize() function
Description
The unserialize() converts to actual data from serialized data.
Version:
(PHP 4 and above)
Syntax:
unserialize(string1)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
string1 | The serialized string. | Required | String |
Return value:
Converted value. The value can be a boolean, array, float, integer or string.
Value Type: Mixed*.
*Mixed : Mixed indicates that the return value may multiple (but not necessarily all) types.
Example:
<?php
$serialized_data = serialize(array('Math', 'Language', 'Science'));
echo $serialized_data . '<br>';
// Unserialize the data
$var1 = unserialize($serialized_data);
// Show the unserialized data;
var_dump ($var1);
?>
Output :
a:3:{i:0;s:4:"Math";i:1;s:8:"Language";i:2;s:7:"Science";} array(3) { [0]=> string(4) "Math" [1]=> string(8) "Language" [2]=> string(7) "Science" }
View the example in the browser
Practice here online :
See also
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/php/function-reference/unserialize.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics