This is the following JSON Structure over which I m trying to iterate
{
"AS":{
"Query":"vi",
"FullResults":1,
"Results":[
{
"Type":"AS",
"Suggests":[
{
"Txt":"videos",
"Type":"AS",
"Sk":""
},
{
"Txt":"vipjatt",
"Type":"AS",
"Sk":"AS1"
},
{
"Txt":"vit",
"Type":"AS",
"Sk":"AS2"
},
{
"Txt":"vijaya bank",
"Type":"AS",
"Sk":"AS3"
},
{
"Txt":"videocon d2h",
"Type":"AS",
"Sk":"AS4"
},
{
"Txt":"visarev",
"Type":"AS",
"Sk":"AS5"
},
{
"Txt":"vijaya karnataka",
"Type":"AS",
"Sk":"AS6"
},
{
"Txt":"video songs",
"Type":"AS",
"Sk":"AS7"
}
]
}
]
}
}
And this is the code I m using to iterate over it, and trying to access the "Txt" property
$data = $info->get($url);
$content = json_decode($data);
$i = 0;
foreach($content->AS->Results as $item) {
$each = $item->Suggests[$i]->Txt;
$i++;
echo $each;
}
But I only get the access of the first appearance of "Txt" property. Whats wrong with my code ? Why isint it printing every appearance of the "Txt" property??