0
如何从数组中获取特定的字段值?我已经尝试过如下如何获取数组中的特定字段值?
$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" --- }
我试图从这个例子中,上述阵列22获得student_id数据字段。
请帮忙!!!
未定义的属性:MongoId :: $ student_id数据误差是否使用'$ stundent_id' insted的'student_id'的显示 – Nida
? – gmc
这是一个数组,而不是一个对象。试试'$ studentarray2 ['_ id'] ['student_id']' – fpietka