我想帶回selectionId的,並將它們放入我的json響應的數組中,但我無法管理它。我有我的JSON響應爲PHP的JSON數組的特定鍵
[
{
marketId: "1.133102670",
marketName: "2m Hrd",
totalMatched: 39556.86,
runners: [
{
selectionId: 13764229,
runnerName: "Kereman",
handicap: 0,
sortPriority: 1
},
{
selectionId: 11378898,
runnerName: "City Dreamer",
handicap: 0,
sortPriority: 2
},
{
selectionId: 12279462,
runnerName: "Costa Percy",
handicap: 0,
sortPriority: 3
},
{
selectionId: 11316530,
runnerName: "Platos Kode",
handicap: 0,
sortPriority: 4
},
{
selectionId: 11177700,
runnerName: "Parkwarden",
handicap: 0,
sortPriority: 5
}
]
},
{
marketId: "1.133102480",
marketName: "7f Nov Stks",
totalMatched: 23164.32,
runners: [
{
selectionId: 13428423,
runnerName: "Delph Crescent",
handicap: 0,
sortPriority: 1
},
{
selectionId: 13079071,
runnerName: "Red Force One",
handicap: 0,
sortPriority: 2
},
{
selectionId: 13372659,
runnerName: "Porth Swtan",
handicap: 0,
sortPriority: 3
},
{
selectionId: 12943079,
runnerName: "Zoffalee",
handicap: 0,
sortPriority: 4
},
{
selectionId: 13373353,
runnerName: "Snooker Jim",
handicap: 0,
sortPriority: 5
},
{
selectionId: 13763129,
runnerName: "Lineofintelligence",
handicap: 0,
sortPriority: 6
},
{
selectionId: 13437954,
runnerName: "Surrender",
handicap: 0,
sortPriority: 7
},
{
selectionId: 13605452,
runnerName: "Cum Spiro Spero",
handicap: 0,
sortPriority: 8
}
]
}
我的代碼如下所示:
$arr = json_decode($jsonResponse, true);
echo $arr['runners'][0]['selectionId'];
任何想法,我要去的地方錯了,甚至我怎麼能解決這個問題帶回所有選擇的ID在數組中。
在此先感謝您提供的任何幫助或建議。
請eval.in – C2486
,你可以簡單地使用'array_column()添加這個'做 – yoeunes