Bug反序列化数据PHP不起作用

时间:2014-07-28 15:19:19

标签: php serialization

我有这些数据:

{"2":{"label":"","value":"","type":null,"validation":null,"required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"3":{"label":"location","value":"","type":"hidden","validation":"","required":"0","min":"0","max":"1000","tooltip":"","custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"4":{"label":"Email","value":"","type":"email","validation":"email","required":"0","min":"","max":"","tooltip":"field0","custom":"","custom2":"","custom3":"zz","custom4":"","custom5":""},"5":{"label":"divider","value":"Group","type":"divider","validation":"divider","required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"6":{"label":"Nom","value":"nom","type":"text","validation":"","required":"0","min":"0","max":"300","tooltip":"field2","custom":"","custom2":null,"custom3":"zz","custom4":null,"custom5":null},"7":{"label":"Ville","value":"ville","type":"text","validation":"","required":"0","min":"0","max":"300","tooltip":"field3","custom":"","custom2":null,"custom3":"zz","custom4":null,"custom5":null},"8":{"label":"Code postal","value":"57000","type":"text","validation":"","required":"0","min":"0","max":"300","tooltip":"field4","custom":"","custom2":null,"custom3":"zz","custom4":null,"custom5":null},"9":{"label":"Description","value":"des","type":"para","validation":"","required":"0","min":"0","max":"300","tooltip":"field5","custom":"","custom2":null,"custom3":"zz","custom4":null,"custom5":null},"10":{"label":"Note","value":"4","type":"stars","validation":"","required":"0","min":"","max":"","tooltip":"field6","custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"11":{"label":"Note-Reason","value":"","type":"stars","validation":"","required":"0","min":"","max":"","tooltip":"field6","custom":"reason","custom2":null,"custom3":"zz","custom4":null,"custom5":null},"12":{"label":"divider","value":"Group","type":"divider","validation":"divider","required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"13":{"label":"Image","value":"1","type":"upload","validation":"file","required":"0","min":"","max":"","tooltip":"field8","custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"14":{"label":"files","value":"http:\/\/www.test.com\/images.jpg","type":"file0","validation":null,"required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"15":{"label":"name","value":"","type":null,"validation":null,"required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"16":{"label":"title","value":"Form Title","type":null,"validation":null,"required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"17":{"label":"emails","value":",","type":null,"validation":null,"required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"18":{"label":"multi","value":"true","type":null,"validation":null,"required":null,"min":null,"max":null,"tooltip":null,"custom":null,"custom2":null,"custom3":"zz","custom4":null,"custom5":null},"0":{"custom3":"zz","value":"","label":""},"1":{"custom3":"zz","value":"","label":""}}

然后我在PHP中执行此操作以获取图像:

$content = unserialize($data);
echo $content[14]['value'];

没有任何事情发生,错误是什么?

提前致谢

1 个答案:

答案 0 :(得分:-1)

这不是PHP序列化数据,请使用json_decode()

print_r(json_decode($data, true));