ununserialize在php函数中不起作用

时间:2014-07-31 06:50:17

标签: php mysql

我需要显示来自mysql的序列化数据的反序列化数据。我在mysql中以序列化方法存储了一个数据,如下所示:

'a:4:{s:16:"degree_completed";s:3:"Yes";s:10:"experience";s:3:"Yes";s:8:"exp_year";s:1:"3";s:9:"exp_month";s:1:"5";}'

在这里,我想要反序列化它并在php中显示。当我尝试unserialize()时,它会显示错误:

Notice: unserialize(): Error at offset 0 of 115 bytes

所以任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

试试这样:

$Str = 'a:4:{s:16:"degree_completed";s:3:"Yes";s:10:"experience";s:3:"Yes";s:8:"exp_year";s:1:"3";s:9:"exp_month";s:1:"5";}'; 
$Str_new = unserialize($Str);
print_r($Str_new);