php - How would I go about traversing this JSON object? -
how access [0] -> array() located below , retrieve [title] "spirited away" iterating on array?
array ( [@attributes] => array ( [version] => 2.0 ) [channel] => array ( [title] => site title [link] => site/ [language] => en-us [category] => [image] => array ( [title] => site [url] => http://example.com [link] => example.com ) [item] => array ( [0] => array ( [title] => spirited away [pubdate] => date [category] => movies [link] => linkhere [enclosure] => array ( [@attributes] => array ( [url] => someurlhere [length] => length [type] => application/x-bittorrent ) )
i'm trying iterate on array using foreach loop it's outputting nothing. post code code section of question long. i'm using php , nothing have tried far working.
this json code generated xml document using json_encode , decoded using json_decode json object.
comment answer correct.
to loop through particular array structure its:
foreach ( $array['channel']['item'] $x){ echo $x['title']; }
Comments
Post a Comment