5 Array
(
[0] => stdClass Object ( [question_id] => 1 [question_id_count] => 3 )
[1] => stdClass Object ( [question_id] => 2 [question_id_count] => 3 )
[2] => stdClass Object ( [question_id] => 3 [question_id_count] => 3 )
[3] => stdClass Object ( [question_id] => 4 [question_id_count] => 5 )
[4] => stdClass Object ( [question_id] => 5 [question_id_count] => 3 )
)
这里我需要输出3,键 - question_id_count
具有值3
答案 0 :(得分:0)
您可以迭代数组,并在当前对象属性匹配时保存密钥:
$outerKey = null;
foreach($array as $key => $value){
if($value->question_id == 3){
$outerKey = $key;
break;
}
}
var_dump($outerKey); //int(2)