$a = 'a:2:{i:1;a:5:{s:8:34;pic_sort";i:2;s:9:"pic_check";b:1;s:10:"pic_select";i:56;s:8:"pic_path";s:1:"ergregerg";s:8:"pic_link";s:2:"wesaddasd";}i:2;a:5:{s:8:"pic_sort";i:2;s:9:"pic_check";b:0;s:10:"pic_select";i:57;s:8:"pic_path";s:10:"4444";s:8:"pic_link";s:14:"http://fafa.com";}}';
print_r(unserialize($a));
问题缘故原由:该当是从数据库中取出的编码和页面的编码不一致造成的。
办理方案:自定义如下的函数调用就可以了
print_r(mb_unserialize($a));
function mb_unserialize($serial_str) {
$out = preg_replace('!s:(\d+):"(.?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
return unserialize($out);
}