I have this following php file that is supposed to loop through a json array and print the necessary information. But I am getting an error in browser which i don't know why it is shown."( ! ) Parse error: syntax error, unexpected 'foreach' (T_FOREACH) in C:\wamp\www\bootstrap-dist\jsonpost.php on line 15". Can someone help me to solve this.
<?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;
}
?>