大量の json ファイルを取得し、それらのファイル内の情報からリンクを作成して、再帰的にファイルにアクセスする必要があります。
{
"_v" : "12.2",
"categories" : [ {
"id" : "boys-hats-and-beanies",
"name" : "Hats & Beanies"
}
]
}
そのため、別のURLを作成して、ファイルの内容を取得する必要があります
http://xxx.xxx/?id=boys-hats-and=beanies.json
そのファイル内で、もう一度やり直す必要があるかもしれません。私が今持っているように、必要な情報を多くの配列に入れます。階層を維持したいと思います。
$allLinks['root'] = array();
$allLinks['firstLevel'] = array();
$allLinks['secondLevel'] = array();
$allLinks['thirdLevel'] = array();
function getContent($info){
$content = file_get_contents($info);
return json_decode($content, true);
}
$new = getContent('https://xxx.xxx/?id=root');
foreach ($new['categories'] as $name => $value) {
array_push($allLinks['root'], 'https://xxx.xxx/?id='.$value['id']);
}
foreach ($allLinks['root'] as $name => $value) {
$new = getContent($value);
foreach ($new['categories'] as $name => $value) {
array_push($allLinks['firstLevel'], 'https://xxx.xxx/?id='.$value['id']);
}
}
foreach ($allLinks['firstLevel'] as $name => $value) {
$new = getContent($value);
foreach ($new['categories'] as $name => $value) {
array_push($allLinks['secondLevel'], 'https://xxx.xxx/?id='.$value['id']);
}
}
foreach ($allLinks['secondLevel'] as $name => $value) {
$new = getContent($value);
foreach ($new['categories'] as $name => $value) {
array_push($allLinks['thirdLevel'], 'https://xxx.xxx/?id='.$value['id']);
}
}
print_r($allLinks);
だから、私が何をしようとしているのかを見ることができます。どんな助けでも素晴らしいでしょう!