$url = "www.test.com"
$json = file_get_contents($url);
$data = json_decode($json);
foreach($data as $mydata) {
$id = $mydata->id;
$url2 = "www.test.com/$id";
$json2 = file_get_contents($url2);
$data2 = json_decode($json2);
var_dump($data2); // seems to always be null?? :(
foreach($data2 as $mydata2) {
.............
}
}
我得到的错误是警告:为 foreach() 提供的参数无效,这是因为 data2 不是数组....
猜想我不能像我一样堆叠 file_get_contents() 。有没有解决的办法?