[英]Need help in JSON Phrase php array
我在使用PHP解析JSON時遇到一些困難,請幫助我如何使用php顯示JSON項目的“ closePrice”。
我嘗試通過循環數組進行短語表達,但沒有得到。
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'];
}
}
}
請幫我..
問候,Ashok
嘗試這個
$arrJson = json_decode($strJson);
echo $arrJson->data[0]->closePrice;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.