Как ссылаться на внутренний массив в объекте bson / json?

У меня есть данные BSON / JSON, как выходной как

         {"waitedMS":0,"result":[{"_id":{"$id":"58131c7799fbad4c1d000205"},"fullname":"Deborah Cheryl Fox","firstmiddle":"Deborah Cheryl","firstlast":"Deborah Fox","student":{"_id":{"$id":"58131c7799fbad4c1d000205"},"student_id":5,"registration_temp_perm_no":"4","roll_no":4,"admission_date":"01\/07\/2016","first_name":"Deborah","middle_name":"Cheryl","last_name":"Fox","dob":"14\/09\/2000","gender":"Male","blood_group":"A+","birth_place":"R S","nationality":"Indian","language":"English","religion":"Agnostic","address_line1":"30933 Anderson Way","address_line2":"97 Lotheville Road","city":"R S","state":"Gujarat","pincode":"India","country":"India","phone1":"919039180422","phone2":"917681559405","email":"[email protected]","is_sms_enabled":"Yes","is_active":1,"has_finished":0,"student_category":"5","course":"58131c7099fbad4c1d0001c2","Biometric_ID":"4","siblings":"Cheryl Fox","guardian_name":"Cheryl Fox","guardian_occupation":"Data Coordiator","guardian_qualification":"Senior Quality Engineer","guardian_email_id":"[email protected]","gaurdain_contact_details":"914519201577","guardian_relationship":"sapien","height":"4.4","weight":"44.8","allergies":"","batch":2,"academicyear":"2015","batchhistory":[{"batchid":2,"academic_year":"2015","course":"58131c7099fbad4c1d0001c2","sequenceno":1,"courseId":{"$id":"58131c7099fbad4c1d0001c2"}},{"batchid":3,"academic_year":"2016","course":"58131c7099fbad4c1d0001c2","sequenceno":2,"courseId":{"$id":"58131c7099fbad4c1d0001c2"}}],"uploads":{"profile_pic":"58131c7799fbad4c1d00020510.jpg"},"routearray":[{"routeid":2,"academicyear":"2016","current":1,"vehicleno":"JK01S8764","dateofassignment":"10\/30\/2016"}],"HostelAlloted":{"Food Preferences":"Both","Hostel":{"$id":"581647da99fbad9421000029"},"Floor":"Floor_1","RoomNumber":1,"Approved":"yes","Approved On":{"sec":1477852200,"usec":0},"Academic Year":"2016"},"HostelAllotmentHistory":[{"Food Preferences":"Both","Hostel":{"$id":"581647da99fbad9421000029"},"Floor":"Floor_1","RoomNumber":1,"Approved":"yes","Approved On":{"sec":1477852200,"usec":0},"Academic Year":"2016"}],"created_at":null,"updated_at":"","courseId":{"$id":"58131c7099fbad4c1d0001c2"}}}....
....
],"ok":1}

После написания этого $cursor = $output["result"];
Я могу получить только результат, как показано ниже

        [{"_id":{"$id":"58131c7799fbad4c1d000205"},"fullname":"Deborah Cheryl Fox","firstmiddle":"Deborah Cheryl","firstlast":"Deborah Fox","student":{"_id":{"$id":"58131c7799fbad4c1d000205"},"student_id":5,"registration_temp_perm_no":"4","roll_no":4,"admission_date":"01\/07\/2016","first_name":"Deborah","middle_name":"Cheryl","last_name":"Fox","dob":"14\/09\/2000","gender":"Male","blood_group":"A+","birth_place":"R S","nationality":"Indian","language":"English","religion":"Agnostic","address_line1":"30933 Anderson Way","address_line2":"97 Lotheville Road","city":"R S","state":"Gujarat","pincode":"India","country":"India","phone1":"919039180422","phone2":"917681559405","email":"[email protected]","is_sms_enabled":"Yes","is_active":1,"has_finished":0,"student_category":"5","course":"58131c7099fbad4c1d0001c2","Biometric_ID":"4","siblings":"Cheryl Fox","guardian_name":"Cheryl Fox","guardian_occupation":"Data Coordiator","guardian_qualification":"Senior Quality Engineer","guardian_email_id":"[email protected]","gaurdain_contact_details":"914519201577","guardian_relationship":"sapien","height":"4.4","weight":"44.8","allergies":"","batch":2,"academicyear":"2015","batchhistory":[{"batchid":2,"academic_year":"2015","course":"58131c7099fbad4c1d0001c2","sequenceno":1,"courseId":{"$id":"58131c7099fbad4c1d0001c2"}},{"batchid":3,"academic_year":"2016","course":"58131c7099fbad4c1d0001c2","sequenceno":2,"courseId":{"$id":"58131c7099fbad4c1d0001c2"}}],"uploads":{"profile_pic":"58131c7799fbad4c1d00020510.jpg"},"routearray":[{"routeid":2,"academicyear":"2016","current":1,"vehicleno":"JK01S8764","dateofassignment":"10\/30\/2016"}],"HostelAlloted":{"Food Preferences":"Both","Hostel":{"$id":"581647da99fbad9421000029"},"Floor":"Floor_1","RoomNumber":1,"Approved":"yes","Approved On":{"sec":1477852200,"usec":0},"Academic Year":"2016"},"HostelAllotmentHistory":[{"Food Preferences":"Both","Hostel":{"$id":"581647da99fbad9421000029"},"Floor":"Floor_1","RoomNumber":1,"Approved":"yes","Approved On":{"sec":1477852200,"usec":0},"Academic Year":"2016"}],"created_at":null,"updated_at":"","courseId":{"$id":"58131c7099fbad4c1d0001c2"}}},
....
....

Теперь я хочу получить массив студентов только в курсоре. Я написал
$ cursor = $ output [«result»] [«student»].

Выдает ошибку «неопределенное сообщение об ошибке индекса».

1

Решение

Попробуй это

$cursor = $output["result"][0]['student'];

$students = array_map(function($v){return $v['student'];}, $output["result"]);
0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]