-4
"data": {
    "id": 9,
    "name": "tala",
    "role": "Student",
    "email": "tala@gmail.com",
    "students": [
        {
            "id": 1,
            "name": "tala",
            "type": "Master_Degree",
            "year": "third",
            "Semester": null,
            "specializations": "جراحة",
            

        }
    ]
},

I used to get email by doing this: response['data']['email']

how could I get the 'type' from response['data']['student'] ??

lagbox
  • 48,571
  • 8
  • 72
  • 83

1 Answers1

0

in your data object , students are an array of objects !

so many students can be added to it !

to access to a student attribute you have to loop into the students array .

$students = response["data"]["students"];

foreach($students as $student ) {
  //access to each student in your list
  // do what ever you want
}
Ala Chebil
  • 451
  • 1
  • 8
  • 19