我有以下的php文件,应该通过json数组循环并打印必要的信息。 “(!)解析错误:语法错误,意外的'foreach'(T_FOREACH)在C:\ wamp \ www \ bootstrap-dist \ jsonpost中。第15行的php“。有人可以帮我解决这个问题吗?无法解析json数组php
<?php
$jArray ='{ "books":[{"id":"01",
"language": "Java",
"edition": "third",
"author": "Herbert Schildt"
},
{
"id":"07",
"language": "C++",
"edition": "second"
"author": "E.Balagurusamy"
}]
}'
foreach ($jArray as $obj) { // error in this line
$ProductName = $obj['edition'];
$ProductQuantity= $obj['language'];
echo $ProductName+" "+$ProductQuantity;
}
?>
请使用[JSONLint](http://jsonlint.com/)来验证您的json字符串。 – James