我對JSON非常陌生,我真的需要幫助。所以,我一直在考慮這個$ oldAuctions對象,並使用PHP的json_decode功能(json_decode($oldAuctions, TRUE);
)後返回我的東西像這樣的有11個對象有9組中的每個名稱/值對的...將JSON對象保存在數組中
{
"recent_results": [
{
"closing_yield": "0.800",
"auction_id": "106",
"use_buy_it": "0",
"issuer": "National Bank",
"term": "1 Year",
"is_charity": "1",
"end_date": "12-26-2012",
"closing_price": "100.000000",
"issue_type": "FDICs"
},
{
"closing_yield": "1.090",
"auction_id": "339",
"use_buy_it": "0",
"issuer": "National Bank",
"term": "1 Year",
"is_charity": "1",
"end_date": "12-12-2012",
"closing_price": "100.000000",
"issue_type": "FDICs"
},
{
"closing_yield": "2.000",
"auction_id": "041",
"use_buy_it": "0",
"issuer": "National Bank",
"term": "5 Year",
"is_charity": "1",
"end_date": "09-11-2012",
"closing_price": "100.000000",
"issue_type": "FDICs"
}
]
}
現在我需要抓住每一對並將其值保存在一個數組中。例如,我想抓住auction_id
並將其值保存在一個數組中.....我該怎麼做?
而且,只是爲了簡單的測試目的,我想先打印出來的值...但沒有工作,要麼...
foreach($oldAuctions as $IDs)
{
echo 'Ids: '.$IDs->auction_id;
}
我會很感激你的幫助。謝謝!
你貼什麼樣子的JSON對象_before_解碼它,而不是什麼'json_decode()'返回。 – Barmar
哦,我的PHP不是5.3版本。謝謝! – AlwaysANovice
'$ oldAuctions'包含什麼? JSON字符串或數組? –