My json is
{"productInfoList":[{"prod":"Some Products","price":"someprice"},{"prod":"Another Product","price":"48"}]}
My php code is
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/file.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$voo = curl_exec($ch);
curl_close($ch);
$yf= json_decode($voo,true);
for ($i=0; $i < 5; $i++)
{
$fkname = $yf->{'productInfoList'}[$i]->{'prod'};
echo $i;
echo $fkname;
}
?>
Output is 012345. How can I get product names using json?
The json file is totally fine I checked it using http://jsonviewer.stack.hu/.