0

This seems like it should be simple but I just can't get it to work. I'm working working with a massive PHP object that contains sports teams' data. The portion of this object I'm having trouble with is as follows:

    [team] => stdClass Object
    (
        [296] => stdClass Object
            (
                [id] => 296
                [name] => Home Team
                [abbreviation] => HOME
            )

        [193] => stdClass Object
            (
                [id] => 193
                [name] => Away Team
                [abbreviation] => AWAY
            )

    )

Being that there are multiple matches with multiple teams, each with their own unique ID number, how can I dynamically match the number (not the [id]) that corresponds to each team? In other words, instead of writing team->296->name, how can I write it like team->$team_id->name?

I can't seem to find a solution that works. Any advice would be much appreciated.

Thank you!

Barmar
  • 741,623
  • 53
  • 500
  • 612
DaveyJake
  • 2,361
  • 1
  • 16
  • 19

0 Answers0