0
jsonファイルの束をプルして、それらのファイルの情報からリンクを作成し、再帰的にファイルに移動する必要があります。複数のJSONファイルからの無次元配列
{
"_v" : "12.2",
"categories" : [ {
"id" : "boys-hats-and-beanies",
"name" : "Hats & Beanies"
}
]
}
ように、私は再びそれをしなければならないかもしれませんに行くと
http://xxx.xxx/?id=boys-hats-and=beanies.json
とそのファイル内のファイルの内容を取得するには、別のURLを構築する必要があります。私は今すぐ持っているので、必要な情報を多くの配列に入れて、階層を維持したいと思います。
$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);
私は何を得ようとしているのか分かります。助けて頂ければ幸いです。
'$のreturn'があるべき'私にこの 'アレイ ( を与えるreturn' – deex
[0] =>アレイ ( [0] => https://xxx.xxx?id =ルート ) [1] =>配列 ( [0] => https://xxx.xxx/?id=mens ) ' そしてそうで.. –