1
如何在一個循環中獲得相同的結果/值而不是兩個?從php循環獲取json值
$json = file_get_contents($url)
$data = json_decode($json, true);
$desc = $data["descriptions"];
$assets = $data["assets"];
foreach ($assets as $assItem) {
echo $assItem["assetid"];
}
foreach($desc as $descItem) {
echo descItem["name"];
}
我已經試過類似
$json = file_get_contents($url);
$data = json_decode($json, true);
foreach ($data as $item) {
echo $item["assets"]["assetid"];
echo $item["descriptions"]["name"];
}
引擎收錄到JSON:https://pastebin.com/raw/uA9mvE2e
我刪除了我的答案,因爲問題並不清楚。粘貼'var_dump($ data)'和期望的輸出。這樣我們可以更好地幫助你。 – Jigar
發佈json文件格式 – julekgwa
添加pastebin到主帖子中的json – user3187651