32机器下PHP 整型数值的范围最大不超过2147483647,而有些超出范围的数值在64序列化好的数据标识为整型,在反序列时就可能会出错。
尝试使用以下的办法可以修复此问题:
<?php
function intvalS($s,$num) {
return 's:'.strlen($num).':"'. $num.'";';
}
//示例字符串(ShopEx4.85的规格参数) 13842408991超过2147483647范围
$specval = 'a:1:{i:6;a:3:{i:13842408991;a:5:{s:10:"spec_value";s:6:"黑色";s:9:"spec_type";s:4:"text";s:13:"spec_value_id";s:3:"237";s:10:"spec_image";s:0:"";s:17:"spec_goods_images";s:0:"";}i:13842409012;a:5:{s:10:"spec_value";s:6:"白色";s:9:"spec_type";s:4:"text";s:13:"spec_value_id";s:3:"238";s:10:"spec_image";s:0:"";s:17:"spec_goods_images";s:0:"";}i:13842409023;a:5:{s:10:"spec_value";s:6:"紫色";s:9:"spec_type";s:4:"text";s:13:"spec_value_id";s:2:"31";s:10:"spec_image";s:0:"";s:17:"spec_goods_images";s:0:"";}}}';
$specval = 'a:3:{s:4:"spec";a:1:{i:6;s:6:"紫色";}s:21:"spec_private_value_id";a:1:{i:6;s:11:"13842409023";}s:13:"spec_value_id";a:1:{i:6;s:2:"31";}}';
$v = preg_replace('@(i)\:(\d{8,12});@e',"intvalS('\\1',\\2)",$v);
echo '<pre>',print_r(unserialize($specval)),'</pre>';
?>
(责任编辑:最模板) |