如何访问数组中的对象属性

时间:2019-09-23 11:04:21

标签: php

我有一些代码可以生成其中包含对象的数组,并且我想访问对象值。

   $results = array();
    $std_arr = array();
    $data['examlist'] = $this->exam_model->get($exam);

    foreach ($student_array as $key => $value) {
        $std_arr[] = $value->student_id;
        $results[] = $this->student_model->get_single_student_result($value->student_id);
    }

当我记录结果时,我得到

Array
(
 [0] => Array
 (
     [0] => stdClass Object
     (
         [exam_schedule_id] => 14
         [get_marks] => 23.00
         [id] => 1
         [exam_id] => 1
         [teacher_subject_id] => 1
         [name] => GEO
         [teacher_id] => 16
         [subject_id] => 1
         [code] => Geography
     )
 )
 [1] => Array
  (
     [0] => stdClass Object
         (
             [exam_schedule_id] => 14
             [get_marks] => 0.00
             [id] => 1
             [exam_id] => 1
             [teacher_subject_id] => 1
             [name] => GEO
             [teacher_id] => 16
             [subject_id] => 1
             [code] => Geography
        )

如何访问这些“ stdClass对象”属性?

0 个答案:

没有答案