访问对象内的元素


access element inside object

var_dump($row_games_query)

给出以下内容-

object(MultiCore)#15 (1) {
  ["_data":"MultiCore":private]=>
  array(2) {
    [0]=>
    object(Core)#18 (1) {
      ["_data":"Core":private]=>
      array(2) {
        ["games"]=>
        string(5) "1,2,3"
        ["email"]=>
        string(8) "20012082"
      }
    }
    [1]=>
    object(Core)#17 (1) {
      ["_data":"Core":private]=>
      array(2) {
        ["games"]=>
        string(7) "7,8,9,0"
        ["email"]=>
        string(8) "20012083"
      }
    }
  }
}

如何访问游戏?

我正在尝试以下方法,但无法访问游戏。

  for ($i = 0; $i <= $row_games_query->length(); $i++) {
        $result = $row->get($i);
        $games_over_list = $result->games;
    }

请帮忙。

尝试向 Core 类添加一个函数,例如

public function getGames() {
    return $this->_data; // the array of games
}

并称呼它。