如何使用 Flutter、Laravel 和 PHP 存取 API 回應中「students」數組中的「type」屬性?
P粉744831602
P粉744831602 2024-04-04 19:25:13
0
1
274

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

        }
    ]
},

我曾經透過這樣做來接收電子郵件: 回應['資料']['電子郵件']

如何從回應['data']['student']中取得「類型」? ?

P粉744831602
P粉744831602

全部回覆(1)
P粉311089279

在您的data物件中,學生是一個物件陣列!

可以增加這麼多學生!

要存取學生屬性,您必須循環到學生陣列中。

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

foreach($students as $student ) {
  //access to each student in your list
  // do what ever you want
}
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!