2013-05-07 35 views

回答

4
$string_reddit = file_get_contents("http://reddit.com/hot.json"); 
$json = json_decode($string_reddit, true); 

$children = $json['data']['children']; 
foreach ($children as $child){ 
    $title = $child['data']['title']; 
    $url = $child['data']['url']; 
} 
+0

我加入回声($标题);回声“
”;它似乎只是输出.json中的第一个和最后一个条目。 – Harry 2013-05-07 04:59:09

+0

啊,我错过了解释结构。我的答案已更新。 – luttkens 2013-05-07 05:10:59