所以我在访问多维数组中的值时遇到问题。这是我的 $klasemen->data 的 print_r 结果/数组结构:
Array ( [0] => stdClass Object ( [team] => stdClass Object ( [id] => 5055 [name] => Manchester United ) [breadcrumb] => Array ( [0] => stdClass Object ( [id] => 1 [name] => Bola ) [1] => stdClass Object ( [id] => 2 [name] => Internasional ) [2] => stdClass Object ( [id] => 23 [name] => Liga Premiere ) ) [games_played] => 23 [wins] => 18 [draws] => 2 [losses] => 3 [goals_scored] => 57 [goals_against] => 30 [goals_difference] => 27 [points] => 56 ) [1] => stdClass Object ( [team] => stdClass Object ( [id] => 5057 [name] => Manchester City ) [breadcrumb] => Array ( [0] => stdClass Object ( [id] => 1 [name] => Bola ) [1] => stdClass Object ( [id] => 2 [name] => Internasional ) [2] => stdClass Object ( [id] => 23 [name] => Liga Premiere ) ) [games_played] => 23 [wins] => 15 [draws] => 6 [losses] => 2 [goals_scored] => 45 [goals_against] => 19 [goals_difference] => 26 [points] => 51 )
我想访问比赛的名称(例如 Liga Premiere)并将其打印在我的视图上,但我不断收到"Message: Trying to get property of non-object"。我认为语法或我在面包屑数组中访问数组的方式有问题。我是新手,我对这个多维数组的东西感到困惑 T_T
这是我想打印值时视图上的行代码(我很确定它有问题)。
echo $klasemen->数据->面包屑[2]->名称
无论如何 $klasemen 是包含所有数据的变量。任何人都可以帮助我吗?谢谢!:-)