-2
有取我這個樣子JSON數據的URL: -PHP:如何閱讀從定製JSON
[
{
MatchId: "17792",
MatchDate: "3/20/2017 3:00:00 AM",
MatchStatus: "",
RoundDetails: "الجولة (13)",
ChampionID: "151",
ChampionName: "تصفيات كأس العالم - امريكا الجنوبية",
ChampionLogo: "730109bd-ba13-4906-8349-4cb12609dd1f.png",
Team1ID: "7",
Team1Name: "اوروقواي",
Team1Logo: "457e035b-af0a-4858-bec5-730e2b50735c.png",
Team1Result: "",
Team2ID: "3",
Team2Name: "البرازيل",
Team2Logo: "07df2e50-3ce2-4091-b4a9-8e6e1aa2272d.png",
Team2Result: ""
},
{
MatchId: "17793",
MatchDate: "3/20/2017 3:00:00 AM",
MatchStatus: "",
RoundDetails: "الجولة (13)",
ChampionID: "151",
ChampionName: "تصفيات كأس العالم - امريكا الجنوبية",
ChampionLogo: "730109bd-ba13-4906-8349-4cb12609dd1f.png",
Team1ID: "8",
Team1Name: "كولومبيا",
Team1Logo: "2d68377c-61ec-4c38-a334-3fc1a51e2bbd.png",
Team1Result: "",
Team2ID: "13",
Team2Name: "بوليفيا",
Team2Logo: "b07b9eb3-c49c-46ed-92a0-bb55e7f869fa.png",
Team2Result: ""
}
]
我怎樣才能讀取使用foreach
所有陣列和所有值存儲到表中的數據庫。
我將不勝感激這個例子。
堆棧溢出不是一個「問它,我們爲你做」網站。你有什麼嘗試? –
$ arr_result = json_decode($ json_data,true);現在你得到一組json數據。然後使用foreach你可以訪問元素 –
解碼你的json使用[json_decode](http://php.net/json_decode)然後遍歷它並使用pdo或mysqli擴展插入你的數據到MySQL – hassan