php - Error on getting data from JSON API -
i new php.
currently i'd data json api url: https://kickass.so/json.php?q=test+category:tv&field=seeders&order=desc&page=2
i have tried following:
<?php $query = file_get_contents('https://kickass.so/json.php?q=test+category:tv&field=seeders&order=desc&page=2'); $parsed_json = json_decode($query, true); foreach ($parsed_json $key => $value) { echo $value['title']; } ?>
here i'd want value as:
title, category, link, hash ect.
but i'm getting error:
warning: illegal string offset 'title' in c:\xampp\htdocs\xxxxx\test.php on line 6 k warning: illegal string offset 'title' in c:\xampp\htdocs\xxxxx\test.php on line 6 h warning: illegal string offset 'title' in c:\xampp\htdocs\xxxxx\test.php on line 6 b warning: illegal string offset 'title' in c:\xampp\htdocs\xxxxx\test.php on line 6 e warning: illegal string offset 'title' in c:\xampp\htdocs\xxxxx\test.php on line 6 1 notice: undefined index: title in c:\xampp\htdocs\xxxxx\test.php on line 6
it's still inside array list
:
[title] => kickasstorrents test category:tv [link] => http://kickass.so [description] => bittorrent search: test category:tv [language] => en-us [ttl] => 60 [total_results] => 1002 [list] => array // <------- nesting ( [0] => array ( [title] => simpsons s24e10 test before trying 480p web-dl x264-msd [category] => tv [link] => http://kickass.so/the-simpsons-s24e10-a-test-before-trying-480p-web-dl-x264-msd-t7006138.html [guid] => http://kickass.so/the-simpsons-s24e10-a-test-before-trying-480p-web-dl-x264-msd-t7006138.html [pubdate] => sunday 20 jan 2013 10:57:02 +0000 [torrentlink] => http://torcache.net/torrent/0d616e1f4578942883f9a0bf676dcdda02b1a894.torrent?title=[kickass.so]the.simpsons.s24e10.a.test.before.trying.480p.web.dl.x264.msd [files] => 4 [comments] => 0 .... )
you can point directly inside loop:
foreach ($parsed_json['list'] $key => $value) { echo $value['title']; }
Comments
Post a Comment