我正在研究考试系统,但遇到了无法获得正确结果的问题。我想要答案数组中与问题ID 466相匹配的结果
(
[id] => 234
[firstChoice] => 2
[choice] => 2
[marked] =>
[strikethrough] => Array()
[highlights] =>
[guessed] =>
[difficulty] => easy
[numTimesChanged] =>
[timeElapsed] => 36
)
我有这种类型的答案std类数组。我也有相同类型的问题数组。
Array(
[0] => stdClass Object
(
[id] => 234
[firstChoice] => 2
[choice] => 2
[marked] =>
[strikethrough] => Array
(
)
[highlights] =>
[guessed] =>
[difficulty] => easy
[numTimesChanged] =>
[timeElapsed] => 36
)
[1] => stdClass Object
(
[id] => 466
[firstChoice] => 3
[choice] => 3
[marked] =>
[strikethrough] => Array
(
)
[highlights] =>
[guessed] =>
[difficulty] => easy
[numTimesChanged] =>
[timeElapsed] => 5
)
)
试试这个:
$result = null;
foreach($array as $value){
if($value->id == 466){
$result = $value;
break;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句