Php 如何获取数组中的特定字段值?
如何从数组中获取特定字段值?我试过下面的方法Php 如何获取数组中的特定字段值?,php,Php,如何从数组中获取特定字段值?我试过下面的方法 $studentarray2 =array(); $studentarray2 = $cursor; echo $key = array_search('student_id', $studentarray2); 它不工作 $studentarray2 contains array(49) { ["_id"]=> object(MongoId
$studentarray2 =array();
$studentarray2 = $cursor;
echo $key = array_search('student_id', $studentarray2);
它不工作
$studentarray2 contains
array(49) { ["_id"]=> object(MongoId)#10 (1) { ["$id"]=> string(24) "5715e59399fbad983700002b" } ["student_id"]=> float(22) ["registration_temp_perm_no"]=> string(5) "54321" ["roll_no"]=> string(2) "18" --- }
我正在尝试从上面的数组中获取student_id字段,该数组在本例中为22
请帮忙 我会尝试
$studentarray2[''u id']->student\u id
未定义的属性:MongoId::$student\u id错误显示您是否使用$student\u id
而不是student\u id
?它是一个数组,不是一个对象。请尝试$studentarray2[“学生id”][“学生id”]