我使用的API連接到第三方網站,其返回的結果如下:從數組中獲取數組的值?
stdClass Object
(
[timeFrameStart] => 2017-03-11
[timeFrameEnd] => 2017-03-12
[count] => 1
[fixtures] => Array
(
[0] => stdClass Object
(
[date] => 2017-03-11T15:00:00Z
[status] => FINISHED
[matchday] => 37
[homeTeamName] => Home Team
[awayTeamName] => Away Team
[result] => stdClass Object
(
[goalsHomeTeam] => 0
[goalsAwayTeam] => 0
)
)
)
)
我可以用得到球隊的名字:
foreach($details->fixtures as $record) {
echo $record->homeTeamName;
}
但是我似乎無法瞭解如何從結果數組中獲取goalHomeTeam/goalsAwayTeam值。
foreach($ details-> fixtures as $ record){ echo $ record-> result-> goalsHomeTeam; } – cornelb