Я хочу отфильтровать элементы из объекта ниже, чтобы остался только первый элемент объекта ie 9. Как вариант, я хочу удалить все элементы строки массива, которые не имеют groupid = 9. Я дал ниже объект и выходной объект
Объект
(
[9] => Array
([2] => Array ( [0] => Array ([groupid] => 9,[Id] => 191,[batchCourse_Name] => Hindi,[course_numbering] => 2))
[1] => Array([groupid] => 9,[Id] => 192,[batchCourse_Name] => Sindhi,[course_numbering] => 2)
[2] => Array([groupid] => 9,[Id] => 193,[batchCourse_Name] => French,[course_numbering] => 2))
[6] => Array([0] => Array ([groupid] => 9,[Id] => 185,[batchCourse_Name] => Biology,[course_numbering] => 6)
[1] => Array([groupid] => 9,[Id] => 194,[batchCourse_Name] => Economics,[course_numbering] => 6)))
[10] => Array(
[7] => Array([0] => Array([groupid] => 10,[Id] => 187,[batchCourse_Name] => Electronics I,[course_numbering] => 7)
[1] => Array([groupid] => 10,[Id] => 189,[batchCourse_Name] => Electronics II,[course_numbering] => 7)))
[11] => Array
([7] => Array([0] => Array([groupid] => 11,[Id] => 186,[batchCourse_Name] => Computer Science I,[course_numbering] => 7)
[1] => Array([groupid] => 11,[Id] => 188,[batchCourse_Name] => Computer Science II,[course_numbering] => 7))))
Выходной объект
(
[9] => Array
([2] => Array ( [0] => Array ([groupid] => 9,[Id] => 191,[batchCourse_Name] => Hindi,[course_numbering] => 2))
[1] => Array([groupid] => 9,[Id] => 192,[batchCourse_Name] => Sindhi,[course_numbering] => 2)
[2] => Array([groupid] => 9,[Id] => 193,[batchCourse_Name] => French,[course_numbering] => 2))
[6] => Array([0] => Array ([groupid] => 9,[Id] => 185,[batchCourse_Name] => Biology,[course_numbering] => 6)
[1] => Array([groupid] => 9,[Id] => 194,[batchCourse_Name] => Economics,[course_numbering] => 6))))