Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要JSON短语php数组的帮助吗_Php_Arrays_Json - Fatal编程技术网

需要JSON短语php数组的帮助吗

需要JSON短语php数组的帮助吗,php,arrays,json,Php,Arrays,Json,我在PHP中解析JSON时遇到一些困难,请帮助我如何使用PHP显示JSON项的“closePrice” 我试着通过循环数组来表达语法,但我不明白 JSON数据: { "futLink": "/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=ICICIBANK&instrument=FUTSTK&expiry=31JUL2014&type=-&strike=-", "oth

我在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;

$obj['data'][0]['closePrice']
有什么问题?