JSON響應是單PHP變量JSON響應
[{"id":630770,"t2":"India A","t1":"South Africa A"},
{"id":593454,"t2":"Nottinghamshire","t1":"Kent"},
{"id":593453,"t2":"Northamptonshire","t1":"Warwickshire"},
{"id":593457,"t2":"Sussex","t1":"Worcestershire"},
{"id":593451,"t2":"Hampshire","t1":"Derbyshire"},
{"id":593456,"t2":"Surrey","t1":"Durham"},{"id":593449,"t2":"Essex","t1":"Lancashire"},
{"id":593455,"t2":"Somerset","t1":"Gloucestershire"},
{"id":593452,"t2":"Leicestershire","t1":"Middlesex"},
{"id":593450,"t2":"Glamorgan","t1":"Yorkshire"}]
在PHP中使用JSON DECODE雖然,數組是:
Array
(
[0] => stdClass Object
(
[id] => 630770
[t2] => India A
[t1] => South Africa A
)
[1] => stdClass Object
(
[id] => 593454
[t2] => Nottinghamshire
[t1] => Kent
)
[2] => stdClass Object
(
[id] => 593453
[t2] => Northamptonshire
[t1] => Warwickshire
)
[3] => stdClass Object
(
[id] => 593457
[t2] => Sussex
[t1] => Worcestershire
)
[4] => stdClass Object
(
[id] => 593451
[t2] => Hampshire
[t1] => Derbyshire
)
[5] => stdClass Object
(
[id] => 593456
[t2] => Surrey
[t1] => Durham
)
[6] => stdClass Object
(
[id] => 593449
[t2] => Essex
[t1] => Lancashire
)
[7] => stdClass Object
(
[id] => 593455
[t2] => Somerset
[t1] => Gloucestershire
)
[8] => stdClass Object
(
[id] => 593452
[t2] => Leicestershire
[t1] => Middlesex
)
[9] => stdClass Object
(
[id] => 593450
[t2] => Glamorgan
[t1] => Yorkshire
)
)
我想在葛變量,而不是數組作爲
結果$var = "ON Going Matches $n : $t1 VS $t2\n";
它應該返回
ON Going Matches
1: South Africa A VS India A
2: Kent VS Nottinghamshire
3: Warwickshire VS Northamptonshire
4: Worcestershire VS Sussex
5: Derbyshire VS Hampshire
6: Durham VS Surrey
7: Lancashire VS Essex
8: Gloucestershire VS Somerset
9: Middlesex VS Leicestershire
10: Yorkshire VS Glamorgan
我使用foreach循環它輸出
ON Going Matches
1: South Africa A VS India A
ON Going Matches
2: Kent VS Nottinghamshire
ON Going Matches
3: Warwickshire VS Northamptonshire
ON Going Matches
4: Worcestershire VS Sussex
ON Going Matches
5: Derbyshire VS Hampshire
ON Going Matches
6: Durham VS Surrey
ON Going Matches
7: Lancashire VS Essex
ON Going Matches
8: Gloucestershire VS Somerset
ON Going Matches
9: Middlesex VS Leicestershire
ON Going Matches
10: Yorkshire VS Glamorgan
我怎樣才能得到這個請大家幫我........
謝謝你的作品... –
不客氣,很高興它爲你工作。 – anubhava
@anubhava不錯的在線遊戲。 – Orangepill