我从API返回了JSON数据,并希望使用刀片输出其中的一些数据。
9 => {#670 â¼
+"id": 10300
+"name": "Fallout 3: Mothership Zeta"
+"slug": "fallout-3-mothership-zeta"
+"url": "https://www.igdb.com/games/fallout-3-mothership-zeta"
+"created_at": 1431649834920
+"updated_at": 1532126985619
+"summary": "Defy hostile alien abductors and fight your way off of the massive Mothership Zeta, orbiting Earth miles above the Capital Wasteland. Mothership Zeta takes Fall â¶"
+"collection": 3
+"rating": 77.763623864376
+"popularity": 1.3333333333333
+"total_rating": 77.763623864376
+"total_rating_count": 29
+"rating_count": 29
+"game": 15
+"games": array:10 [â¶]
+"tags": array:4 [â¶]
+"developers": array:1 [â¶]
+"publishers": array:1 [â¶]
+"category": 1
+"player_perspectives": array:1 [â¶]
+"game_modes": array:1 [â¶]
+"themes": array:1 [â¶]
+"genres": array:2 [â¶]
+"first_release_date": 1249257600000
+"platforms": array:3 [â¶]
+"release_dates": array:3 [â¶]
+"screenshots": array:7 [â¶]
+"cover": {#681 â¼
+"url": "//images.igdb.com/igdb/image/upload/t_thumb/btawsi7cbgcmqlw67tpn.jpg"
+"cloudinary_id": "btawsi7cbgcmqlw67tpn"
+"width": 1061
+"height": 1158
}
}
我希望得到的是我尝试过的封面URL,并循环访问所有JSON数据,这些数据将返回上述10个项目。
@foreach ($game as $games)
<div class="col-md-2">
<img src="" alt="">
<p>{{ $games->name}}</p>
@foreach ($games->cover as $cover)
<p>{{$cover['url']}}</p>
@endforeach
</div>
@endforeach
目前,这是我的循环中的内容,我得到了这个错误
非法字符串偏移量“url”