PHP Parse JSON [HARD]


PHP Parse JSON [HARD]

我有这样的脚本:

$jsonItems = file_get_contents('http://media1.clubpenguin.com/play/en/web_service/game_configs/paper_items.json');
$objDecode = json_decode($jsonItems, true);
foreach($objDecode as $item){
//Do something
}

这个剧本行得通。我怎么能在不命名所有属性名称的情况下使用这个文件呢?因为有100多个属性名称,我想:http://media1.clubpenguin.com/play/en/web_service/game_configs/paths.json

请帮助我

考虑到SWF链接将始终在此数据集中的内部对象中-您可以这样做(如果不是所有链接都是SWF文件,则可能需要对链接中的扩展名进行可选的第二次检查)

$json = file_get_contents("http://media1.clubpenguin.com/play/en/web_service/game_configs/paths.json");
$data = json_decode($json,true);
foreach($data as $type=>&$links){
    foreach($links as &$link){
        //$link is the link - do what ever you want here
            //if needed check for SWF extension in the link here
    }
}