Home >Backend Development >PHP Tutorial >How to Unserialize a PHP Serialized String?
Understanding and Unserializing Serialized Strings
In your case, you have a serialized string of the following format:
a:2:{i:0;s:7:"Abogado";i:1;s:7:"Notario";}
To answer your questions:
What kind of string is this?
This is a serialized string, a representation of an array in a specific format. It encodes information about the array, including key-value pairs and the types of values.
How can I unserialize it and get the array out of it?
You can unserialize this string using PHP's unserialize() function. Here's an example:
$str = 'a:2:{i:0;s:7:"Abogado";i:1;s:7:"Notario";}'; $result = unserialize($str);
The output of print_r($result) will be:
Array ( [0] => Abogado [1] => Notario )
Important Notes:
The above is the detailed content of How to Unserialize a PHP Serialized String?. For more information, please follow other related articles on the PHP Chinese website!