我在PHP中解析JSON时遇到一些困难,请帮我看看如何显示' closePrice'使用php的JSON项目。
我尝试通过循环数组进行短语但我没有得到。
JSON数据:
{
"futLink": "/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=ICICIBANK&instrument=FUTSTK&expiry=31JUL2014&type=-&strike=-",
"otherSeries": [
"EQ"
],
"lastUpdateTime": "21-JUL-2014 15:29:31",
"tradedDate": "21JUL2014",
"data": [
{
"extremeLossMargin": "5.00",
"cm_ffm": "1,71,144.19",
"bcStartDate": "07-JUN-14",
"change": "0.70",
"buyQuantity3": "32",
"sellPrice1": "1,483.80",
"buyQuantity4": "250",
"sellPrice2": "1,484.00",
"priceBand": "No Band",
"buyQuantity1": "100",
"deliveryQuantity": "23,67,964",
"buyQuantity2": "9",
"cm_adj_low": "756.90",
"sellPrice5": "1,484.60",
"quantityTraded": "40,19,158",
"buyQuantity5": "535",
"sellPrice3": "1,484.25",
"sellPrice4": "1,484.50",
"open": "1,488.00",
"cm_adj_high": "1,593.20",
"low52": "756.90",
"securityVar": "6.97",
"marketType": "N",
"pricebandupper": "1,628.45",
"totalTradedValue": "29,239.31",
"faceValue": "10.00",
"ndStartDate": "-",
"previousClose": "1,480.45",
"symbol": "ICICIBANK",
"varMargin": "7.50",
"lastPrice": "1,481.15",
"pChange": "0.05",
"adhocMargin": "-",
"companyName": "ICICI Bank Limited",
"averagePrice": "1,486.31",
"secDate": "18JUL2014",
"series": "EQ",
"isinCode": "INE090A01013",
"indexVar": "-",
"pricebandlower": "1,332.45",
"totalBuyQuantity": "62,990",
"high52": "1,593.20",
"purpose": "ANNUAL GENERAL MEETING/DIVIDEND RS.23/- PER SHARE",
"cm_adj_low_dt": "28-AUG-13",
"closePrice": "-",
"recordDate": "-",
"cm_adj_high_dt": "16-MAY-14",
"totalSellQuantity": "1,03,069",
"dayHigh": "1,496.65",
"exDate": "05-JUN-14",
"sellQuantity5": "5",
"bcEndDate": "30-JUN-14",
"ndEndDate": "-",
"sellQuantity2": "205",
"sellQuantity1": "90",
"buyPrice1": "1,482.30",
"sellQuantity4": "5",
"buyPrice2": "1,481.70",
"sellQuantity3": "5",
"applicableMargin": "12.50",
"buyPrice4": "1,481.10",
"buyPrice3": "1,481.15",
"buyPrice5": "1,481.00",
"dayLow": "1,476.05",
"deliveryToTradedQuantity": "58.92",
"totalTradedVolume": "19,67,242"
}
],
"optLink": "/marketinfo/sym_map/symbolMapping.jsp?symbol=ICICIBANK&instrument=-&date=-&segmentLink=17&symbolCount=2"
}
我尝试使用下面的代码,但没有成功。
$obj = json_decode($json, true);
foreach ($obj as $item) {
foreach ($item as $data) {
foreach ($data as $d) {
echo $d['closePrice'];
}
}
}
请帮帮我..
此致 阿肖克
答案 0 :(得分:2)
试试这个
$arrJson = json_decode($strJson);
echo $arrJson->data[0]->closePrice;