2017-08-25 175 views
0

提取JSON如何提取JSON如何通過PHP

{"scoreboard":{"lastUpdatedOn":"2017-08-21 6:58:49 PM","gameScore":[{"game":{"ID":"40380","week":"1","scheduleStatus":"Normal","originalDate":null,"originalTime":null,"delayedOrPostponedReason":null,"date":"2017-09-11","time":"7:10PM","awayTeam":{"ID":"70","City":"New Orleans","Name":"Saints","Abbreviation":"NO"},"homeTeam":{"ID":"63","City":"Minnesota","Name":"Vikings","Abbreviation":"MIN"},"location":"TCF Bank Stadium"},"isUnplayed":"true","isInProgress":"false","isCompleted":"false","quarterSummary":null} 

如何提取上述JSON由PHP

$allnfls = $nfls['scoreboard']['gameScore']; 

     foreach($allnfls as $allnfl) 
     { 
      //foreach($allnfld as $allnfl) { 

       $gameid = $allnfl['ID']; 
       echo "<br>".$week = $allnfl['game']['week']; 
} 

回答

0

定義一個變量,並使用json_decode(YourJSONString,真)