I have the following JSON input (it's in a file called customer.json) but cant seem to loop through the values -
{"posts":[
{"post":{"Customer_ID":"A & I","CustomerName":"A & I Products"}},
{"post":{"Customer_ID":"A&A","CustomerName":"A & A Mfg. Co., Inc."}}
]}
The following is the code I've tried and have been working with -
$inputJSON = file_get_contents('/srv/www/htdocs/sandbox/customer.json');
$parsedJSON = json_decode($inputJSON,true);
$parsedJSON = $parsedJSON['posts'];
foreach ($parsedJSON['post'] as $post)
{
$custid = $post['Customer_ID'];
$custnm = $post['CustomerName'];
echo $custid;
echo $custnm;
}
Any help that can be offered would be greatly appreciated. Thanks,