使用php解析json(?)字符串

时间:2012-12-03 16:51:27

标签: php arrays multidimensional-array json

我有一个字符串,更具体地说,这个字符串:

a:16:{s:9:"pseudonym";O:16:"SimpleXMLElement":0:{}s:14:"parallel_title";O:16:"SimpleXMLElement":0:{}s:9:"title_var";O:16:"SimpleXMLElement":0:{}s:6:"series";O:16:"SimpleXMLElement":0:{}s:9:"vol_title";O:16:"SimpleXMLElement":0:{}s:9:"reference";O:16:"SimpleXMLElement":0:{}s:10:"bound_with";O:16:"SimpleXMLElement":0:{}s:15:"general_remarks";O:16:"SimpleXMLElement":0:{}s:6:"copies";O:16:"SimpleXMLElement":1:{i:0;s:1:"1";}s:11:"remarks_BPH";O:16:"SimpleXMLElement":0:{}s:3:"ICN";O:16:"SimpleXMLElement":1:{i:0;s:4:"neen";}s:10:"provenance";O:16:"SimpleXMLElement":0:{}s:7:"binding";O:16:"SimpleXMLElement":0:{}s:10:"size_hxwxd";O:16:"SimpleXMLElement":0:{}s:6:"BookID";O:16:"SimpleXMLElement":1:{i:0;s:4:"6271";}s:5:"repro";O:16:"SimpleXMLElement":0:{}}

是否有可能以某种方式解析此字符串?我需要在列表中显示键和值。我尝试使用json_decode但它没有返回任何内容,即使第二个参数设置为true

json_decode($string,true);

2 个答案:

答案 0 :(得分:7)

它不是JSON,它是序列化的PHP。使用unserialize()

答案 1 :(得分:1)

它是序列化对象

详细了解PHP website