Php 取消序列化不返回数组

Php 取消序列化不返回数组,php,serialization,Php,Serialization,未序列化函数未在数组中返回 这是我回显时的序列化数据 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

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

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

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时,它会给出布尔值(false)


请帮助

您的序列化数据格式不正确。试试这个:

$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));
快速修复:

$serialized = preg_replace_callback(
                    '!s:(\d+):"(.*?)";!', 
                    function($m) { 
                        return 's:'.strlen($m[2]).':"'.$m[2].'";'; 
                    }, 
                $serialized);

可能它不是不可序列化的。这就是它返回false的原因,您是否也收到通知,以及您是否可以显示如何序列化数组?@Sudhir wht它不能取消序列化我正在使用$items\u desc=unserialize(htmlspecialchars\u decode(html\u entity\u decode(trim($item\u row->contents));我尝试了所有的组合,但没有组合$item_row->内容序列化。。。?因为unserialize()接受单个序列化变量并将其转换回PHPvalue@Sudhir是的,它是序列化的。我正在处理gocart(codeigniter),但我有单独的文件,这就是我编写查询的原因。在gocart的后端,它正在对其进行反序列化,并正在处理perfectunserialize():偏移量为2467的1451处出错