コントローラからモデルvar_dumpにデータを送信しています
$score
示されている通りです
Array
(
[assessment_score] => Array
(
[0] => Array
(
)
[1] => Array
(
[0] => stdClass Object
(
[id] => 3
[score] => 4
[assessment_id] => 1
[assessor_id] => 24
[level_test] => 2
)
[1] => stdClass Object
(
[id] => 4
[score] => 5
[assessment_id] => 1
[assessor_id] => 24
[level_test] => 3
)
)
[2] => Array
(
)
[3] => Array
(
)
)
[assessment_msg] => Array
(
[0] => Array
(
)
[1] => Array
(
[0] => stdClass Object
(
[id] => 1
[user_id] => 21
[start_time] => 2012-05-20 20:45:30
[status] => 0
[end_time] => 2012-05-21 20:45:30
[assessor1] => 25
[assessor2] => 24
[assessor3] => 0
[gd_msg] =>
[gd_pf] =>
[csgd_msg] =>
[csgd_pf] =>
[pi_msg] =>
[pi_pf] =>
[wr_msg] =>
[wr_pf] =>
)
)
[2] => Array
(
[0] => stdClass Object
(
[id] => 4
[user_id] => 28
[start_time] => 2012-05-23 13:38:32
[status] => 0
[end_time] => 2012-05-24 13:38:32
[assessor1] => 23
[assessor2] => 0
[assessor3] => 0
[gd_msg] =>
[gd_pf] =>
[csgd_msg] =>
[csgd_pf] =>
[pi_msg] =>
[pi_pf] =>
[wr_msg] =>
[wr_pf] =>
)
)
[3] => Array
(
[0] => stdClass Object
(
[id] => 3
[user_id] => 22
[start_time] => 2012-05-14 14:00:41
[status] => 0
[end_time] => 2012-05-17 14:00:41
[assessor1] => 25
[assessor2] => 0
[assessor3] => 0
[gd_msg] =>
[gd_pf] =>
[csgd_msg] =>
[csgd_pf] =>
[pi_msg] =>
[pi_pf] =>
[wr_msg] =>
[wr_pf] =>
)
)
)
)
しかし、私がそれを評価しているとき
$user_score = array();
if (count($score['assessment_score'][$i]) > 0) {
foreach ($score['assessment_score'][$i] as $score) {
$user_score[$score->level_test] = $score->score;
}
}
エラーをスローします
( ! ) Fatal error: Cannot use object of type stdClass as array
in C:\xampp\htdocs\ci\application\views\users\users_score_list.php
行に
if (count($score['assessment_score'][$i]) > 0) {
それを解決する方法は?それは私のさらなる処理を壊すので、致命的なエラーを回避する方法。以下はvar_exportです
array (
'assessment_score' =>
array (
0 =>
array (
),
1 =>
array (
0 =>
stdClass::__set_state(array(
'id' => '3',
'score' => '4',
'assessment_id' => '1',
'assessor_id' => '24',
'level_test' => '2',
)),
1 =>
stdClass::__set_state(array(
'id' => '4',
'score' => '5',
'assessment_id' => '1',
'assessor_id' => '24',
'level_test' => '3',
)),
),
2 =>
array (
),
3 =>
array (
),
),
'assessment_msg' =>
array (
0 =>
array (
),
1 =>
array (
0 =>
stdClass::__set_state(array(
'id' => '1',
'user_id' => '21',
'start_time' => '2012-05-20 20:45:30',
'status' => '0',
'end_time' => '2012-05-21 20:45:30',
'assessor1' => '25',
'assessor2' => '24',
'assessor3' => '0',
'gd_msg' => '',
'gd_pf' => '',
'csgd_msg' => '',
'csgd_pf' => '',
'pi_msg' => '',
'pi_pf' => '',
'wr_msg' => '',
'wr_pf' => '',
)),
),
2 =>
array (
0 =>
stdClass::__set_state(array(
'id' => '4',
'user_id' => '28',
'start_time' => '2012-05-23 13:38:32',
'status' => '0',
'end_time' => '2012-05-24 13:38:32',
'assessor1' => '23',
'assessor2' => '0',
'assessor3' => '0',
'gd_msg' => '',
'gd_pf' => '',
'csgd_msg' => '',
'csgd_pf' => '',
'pi_msg' => '',
'pi_pf' => '',
'wr_msg' => '',
'wr_pf' => '',
)),
),
3 =>
array (
0 =>
stdClass::__set_state(array(
'id' => '3',
'user_id' => '22',
'start_time' => '2012-05-14 14:00:41',
'status' => '0',
'end_time' => '2012-05-17 14:00:41',
'assessor1' => '25',
'assessor2' => '0',
'assessor3' => '0',
'gd_msg' => '',
'gd_pf' => '',
'csgd_msg' => '',
'csgd_pf' => '',
'pi_msg' => '',
'pi_pf' => '',
'wr_msg' => '',
'wr_pf' => '',
)),
),
),
)