0

I'm using an API to connect to a third party site which is returning the following results:

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
                        )

                )

        )

)

I can get the team names using:

foreach($details->fixtures as $record) { 
    echo $record->homeTeamName; 
}

however I can't seem to figure out how to get the goalsHomeTeam/goalsAwayTeam values from within the result array.

Rwd
  • 34,180
  • 6
  • 64
  • 78
BN83
  • 902
  • 3
  • 9
  • 29

1 Answers1

1

Try:

foreach($details->fixtures as $record) {
    echo $record->homeTeamName . '<br />';
    echo $record->result->goalsHomeTeam . '<br />';
    echo $record->result->goalsAwayTeam  . '<br />';
}

Hope this helps!

Rwd
  • 34,180
  • 6
  • 64
  • 78