php unserialize返回空的解决办法
$need_info值为序列,是有值的,但是用反序列函数 返回的是控制,如何解决?
元素模板为您解答,在unserialize前先把$need_info使用下面代码
UTF8
$need_info= preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $need_info); $need_info= str_replace("\r", "", $need_info);
GBK
$need_info = preg_replace('!s:(\d+):"(.*?)";!se', '"s:".strlen("$2").":\"$2\";"', $need_info ); $need_info= str_replace("\r", "", $need_info);