How can I navigate this JSON

0

I've been trying to traverse this JSON but it gives me the blank value when doing echo.

{
  "Score": {
    "GameKey": "201811102",
    "SeasonType": 1,
    "Season": 2018,
    "Week": 11,
    "Date": "2018-11-18T13:00:00",
    "AwayTeam": "DAL",
    "HomeTeam": "ATL",
    "AwayScore": 24,
    "HomeScore": 21,
    "Channel": null,
    "PointSpread": -3.9,
    "OverUnder": 55.8,
    "Quarter": "F",
    "TimeRemaining": null,
    "Possession": null,
    "Down": null,
    "Distance": "Scrambled",
    "YardLine": null,
    "YardLineTerritory": null,
    "RedZone": null,
    "AwayScoreQuarter1": 3,
    "AwayScoreQuarter2": 0,
    "AwayScoreQuarter3": 3,
    "AwayScoreQuarter4": 18,
    "AwayScoreOvertime": 0,
    "HomeScoreQuarter1": 0,
    "HomeScoreQuarter2": 6,
    "HomeScoreQuarter3": 3,
    "HomeScoreQuarter4": 11,
    "HomeScoreOvertime": 0,
    "HasStarted": true,
    "IsInProgress": false,
    "IsOver": true,

I'm trying with this code:

$datos =  file_get_contents($url);
$evento = json_decode($datos,true);
foreach ($evento as $key=>$value) { 
echo $evento[$key]->Score->Week;
}
    
asked by Carlos Maldonado 22.11.2018 в 21:38
source

1 answer

2

If the JSON is the same as the one you are publishing, you do not need to do foreach , with the simple echo of doing json_decode you can use the array.

simply by doing echo $evento['Score']['Week']; you will be able to visualize the information.

    
answered by 22.11.2018 / 22:12
source