0

反序列化函数未在数组中返回。

这是我回显时的序列化数据。

a:31:{s:2:"id";s:2:"71";s:3:"sku";s:6:"cp1038";s:4:"name";s:25:"Dual tone stripped pillow";s:4:"slug";s:29:"dual-tone-stripped-pillow-222";s:8:"route_id";s:3:"152";s:11:"description";s:1259:"

Address Home, a brand new Luxe Lifestyle boutique, Everything from plus bed and table Linen to cushions, curtain and upholstery fabric in silk, cotton, satin, velvet, jacquard and polyester, embellished with foil printing, contemporary embroidery, crystals, quilting and other types of texturing, including tiny metallic pieces. The current range, which shows traces of Moroccan and French textile influences, but is all about very �now� color combinations - whites and whites; chocolate with teal and copper; black with white and silver; fuchsia, orange depth. coordinate easily with elaborate accessories; German hand-blown glass vases, lamps, lights, serving and dining pieces, glassware, flowers and candles. Even some fab spmdly-legged French chairs, handcrafted from acrylic. Call it my nesting instinct or magpie syndrome, but i just can�t re sist seeking out stuff to enhance my bachelorettepad. Whenever there�s a new home decor store on the horizon, I�m usually one of the early check-outers. Recently, my seeker sense was tingling so much I JUST knew there was something really exciting coming up. And how right I was!
";s:7:"excerpt";s:32:"Dual tone stripped pillow 2 exec";s:5:"price";s:7:"1000.00";s:9:"saleprice";s:4:"0.00";s:13:"free_shipping";s:1:"0";s:9:"shippable";s:1:"1";s:7:"taxable";s:1:"1";s:14:"fixed_quantity";s:1:"0";s:6:"weight";s:2:"10";s:11:"track_stock";s:1:"1";s:16:"related_products";s:0:"";s:6:"images";s:460:"{"81503e57d46823464db9e990faa600b0":{"filename":"81503e57d46823464db9e990faa600b0.jpg","alt":"showcase","caption":""},"ba103b97070ede81acab8f593068ece1":{"filename":"ba103b97070ede81acab8f593068ece1.jpg","alt":"","caption":""},"cdd790bd0a17f93af430d663cde823e1":{"filename":"cdd790bd0a17f93af430d663cde823e1.jpg","alt":"","caption":""},"769557dd643978d50d3bd76e5ca3211d":{"filename":"769557dd643978d50d3bd76e5ca3211d.jpg","alt":"","caption":"","primary":true}}";s:9:"seo_title";s:0:"";s:4:"meta";s:0:"";s:7:"enabled";s:1:"1";s:5:"color";s:1:"3";s:4:"size";s:2:"20";s:14:"child_products";s:1:"0";s:15:"mapped_products";s:11:"73,37,36,29";s:10:"hover_name";s:15:"Dual Tone Hover";s:10:"base_price";s:7:"1000.00";s:9:"file_list";a:0:{}s:12:"post_options";s:0:"";s:5:"is_gc";b:0;s:8:"quantity";d:2;s:8:"subtotal";d:2000;}

当我对它进行反序列化并对其进行 var_dump 时,它给了我布尔值(假)。我尝试使用 htmlspecialchars()、trim()、stripslashes() 但不工作

请帮忙

4

2 回答 2

0

您的序列化数据格式错误。尝试这个:

$serialized = 'a:31:{s:2:"id";s:2:"71";s:3:"sku";s:6:"cp1038";s:4:"name";s:25:"Dual tone stripped pillow";s:4:"slug";s:29:"dual-tone-stripped-pillow-222";s:8:"route_id";s:3:"152";s:11:"description";s:1139:"Address Home, a brand new Luxe Lifestyle boutique, Everything from plus bed and table Linen to cushions, curtain and upholstery fabric in silk, cotton, satin, velvet, jacquard and polyester, embellished with foil printing, contemporary embroidery, crystals, quilting and other types of texturing, including tiny metallic pieces. The current range, which shows traces of Moroccan and French textile influences, but is all about very �now� color combinations - whites and whites; chocolate with teal and copper; black with white and silver; fuchsia, orange depth. coordinate easily with elaborate accessories; German hand-blown glass vases, lamps, lights, serving and dining pieces, glassware, flowers and candles. Even some fab spmdly-legged French chairs, handcrafted from acrylic. Call it my nesting instinct or magpie syndrome, but i just can�t re sist seeking out stuff to enhance my bachelorettepad. Whenever there�s a new home decor store on the horizon, I�m usually one of the early check-outers. Recently, my seeker sense was tingling so much I JUST knew there was something really exciting coming up. And how right I was!";s:7:"excerpt";s:32:"Dual tone stripped pillow 2 exec";s:5:"price";s:7:"1000.00";s:9:"saleprice";s:4:"0.00";s:13:"free_shipping";s:1:"0";s:9:"shippable";s:1:"1";s:7:"taxable";s:1:"1";s:14:"fixed_quantity";s:1:"0";s:6:"weight";s:2:"10";s:11:"track_stock";s:1:"1";s:16:"related_products";s:0:"";s:6:"images";s:460:"{"81503e57d46823464db9e990faa600b0":{"filename":"81503e57d46823464db9e990faa600b0.jpg","alt":"showcase","caption":""},"ba103b97070ede81acab8f593068ece1":{"filename":"ba103b97070ede81acab8f593068ece1.jpg","alt":"","caption":""},"cdd790bd0a17f93af430d663cde823e1":{"filename":"cdd790bd0a17f93af430d663cde823e1.jpg","alt":"","caption":""},"769557dd643978d50d3bd76e5ca3211d":{"filename":"769557dd643978d50d3bd76e5ca3211d.jpg","alt":"","caption":"","primary":true}}";s:9:"seo_title";s:0:"";s:4:"meta";s:0:"";s:7:"enabled";s:1:"1";s:5:"color";s:1:"3";s:4:"size";s:2:"20";s:14:"child_products";s:1:"0";s:15:"mapped_products";s:11:"73,37,36,29";s:10:"hover_name";s:15:"Dual Tone Hover";s:10:"base_price";s:7:"1000.00";s:9:"file_list";a:0:{}s:12:"post_options";s:0:"";s:5:"is_gc";b:0;s:8:"quantity";d:2;s:8:"subtotal";d:2000;}';
print_r(unserialize($serialized));
于 2013-10-08T10:04:04.700 回答
0

快速解决:

$serialized = preg_replace_callback(
                    '!s:(\d+):"(.*?)";!', 
                    function($m) { 
                        return 's:'.strlen($m[2]).':"'.$m[2].'";'; 
                    }, 
                $serialized);
于 2019-09-12T08:31:40.267 回答