这是一个有点初学者问题。我正在使用一个JSON文件,它看起来像这样:
{"nodes":
[{"node":
{"Vocabulary name":"Bestseller Format",
"Term":"Hardcover Fiction",
"Bestseller1":"9780470227800",
"Bestseller2":"9781451617962",
"Bestseller3":"9781439167397",
"Bestseller4":"9781617750106",
"Bestseller5":"9780385533300",
"Bestseller6":"9780670022526",
"Bestseller7":"9781609530358",
"Bestseller8":"9780132358040",
"Bestseller9":"9780596159771",
"Bestseller10":"9780151014163",
"Bestseller11":"9780393334807",
"Bestseller12":"9780805090161"}
}]
}
我正在尝试在php中解析它。 我已经编写了一个脚本
<?php
$jsonurl = "http://www.xtracrunchy.com/pandpnewlook/?q=pandp/bestsellers";
$json = file_get_contents($jsonurl,NULL, NULL, 0, 1000);
$json_output = json_decode($json,true);
$bestseller_array = $json_output[nodes][0][node];
foreach ($bestseller_array as $key => $value)
{
print $key;
print " - ";
print $value;
print "<br />";
}
?>
我希望最终能够建立一个畅销书ISBN的有序列表,但是当我运行这个脚本时,唯一的输出是
词汇名称 - 畅销书格式 术语 - 硬面小说
当我添加打印计数($bestseller_array);时,我只得到2个元素的数组。
任何帮助都将不胜感激。
code
标签放置代码吗?并且让所有内容易读... 谢谢 :D - fingermanprint_r($json_output)
\n http://php.net/manual/zh/function.print-r.php - fingerman