Json Response array loop
I have read pages and pages and i'm lost on how to proceed. I am trying to extract the price from a json array but the data I'm being provided seems to require i have the price first?
var_dump(json_decode($resp, true));
$Data= json_decode($resp,true);
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
array) { ["status"]=> "SUCCESS" ["Date"]=> array(1) {
["2018-11-23"]=>
array() {
["115.5"]=>
array() {
[0]=>
array(46) {
["Price"]=> float(115.5)
["Date"]=> int(1543028400000)
}
}
["116.0"]=>
array() {
[0]=>
array() {
["Price"]=> float(116.0)
["Date"]=> int(1543028400000)
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
a partial snippet of the actual json:
{"symbol":"GLD","status":"SUCCESS","underlying":null,"strategy":"SINGLE","interval":null,"isDelayed":true,"isIndex":false,"interestRate":2.64581,"underlyingPrice":115.56,"volatility":29.0,"daysToExpiration":0.0,"callExpDateMap":{"2018-11-23:0":{"115.5":[{"putCall":"CALL","symbol":"GLD_112318C115.5","description":"GLD Nov 23 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.17,"ask":0.28,"last":0.22,"mark":0.23,"bidSize":132,"askSize":20,"lastSize":0,"highPrice":0.38,"lowPrice":0.13,"openPrice":0.0,"closePrice":0.53,"totalVolume":351,"tradeDate":null,"tradeTimeInLong":1542995987379,"quoteTimeInLong":1542995999544,"netChange":-0.31,"volatility":-999.0,"delta":1.0,"gamma":0.0,"theta":-0.008,"vega":0.0,"rho":0.003,"openInterest":2231,"timeValue":-0.05,"theoreticalOptionValue":-999.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-58.63,"markChange":-0.31,"markPercentChange":-57.69,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_112318C116","description":"GLD Nov 23 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.0,"ask":0.01,"last":0.01,"mark":0.01,"bidSize":0,"askSize":692,"lastSize":0,"highPrice":0.11,"lowPrice":0.01,"openPrice":0.0,"closePrice":0.26,"totalVolume":2167,"tradeDate":null,"tradeTimeInLong":1542995959548,"quoteTimeInLong":1542995984685,"netChange":-0.25,"volatility":0.0,"delta":0.0,"gamma":0.0,"theta":0.0,"vega":0.0,"rho":0.0,"openInterest":2786,"timeValue":0.01,"theoreticalOptionValue":0.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-96.21,"markChange":-0.26,"markPercentChange":-98.1,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-11-30:7":{"115.5":[{"putCall":"CALL","symbol":"GLD_113018C115.5","description":"GLD Nov 30 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.77,"ask":0.79,"last":0.76,"mark":0.78,"bidSize":22,"askSize":18,"lastSize":0,"highPrice":0.89,"lowPrice":0.73,"openPrice":0.0,"closePrice":0.94,"totalVolume":217,"tradeDate":null,"tradeTimeInLong":1542995943992,"quoteTimeInLong":1542995999810,"netChange":-0.18,"volatility":9.003,"delta":0.582,"gamma":0.253,"theta":-0.042,"vega":0.067,"rho":0.015,"openInterest":755,"timeValue":0.49,"theoreticalOptionValue":0.78,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-19.17,"markChange":-0.16,"markPercentChange":-17.05,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_113018C116","description":"GLD Nov 30 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.52,"ask":0.55,"last":0.53,"mark":0.54,"bidSize":920,"askSize":18,"lastSize":0,"highPrice":0.63,"lowPrice":0.49,"openPrice":0.0,"closePrice":0.69,"totalVolume":1278,"tradeDate":null,"tradeTimeInLong":1542995969283,"quoteTimeInLong":1542995999922,"netChange":-0.16,"volatility":9.165,"delta":0.454,"gamma":0.252,"theta":-0.043,"vega":0.068,"rho":0.011,"openInterest":2948,"timeValue":0.53,"theoreticalOptionValue":0.535,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-23.15,"markChange":-0.15,"markPercentChange":-22.43,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-12-07:14":{"115.5":[{"putCall":"CALL","symbol":"GLD_120718C115.5","description":"GLD Dec 7 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":1.07,"ask":1.1,"last":1.07,"mark":1.09,"bidSize":496,"askSize":22,"lastSize":0,"highPrice":1.16,"lowPrice":1.07,"openPrice":0.0,"closePrice":1.27,"totalVolume":3,"tradeDate":null,"tradeTimeInLong":1542988161634,"quoteTimeInLong":1542995999922,"netChange":-0.2,"volatility":9.532,"delta":0.569,"gamma":0.176,"theta":-0.034,"vega":0.092,"rho":0.027,"openInterest":214,"timeValue":0.8,"theoreticalOptionValue":1.085,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1544238000000,"d
php arrays json
|
show 5 more comments
I have read pages and pages and i'm lost on how to proceed. I am trying to extract the price from a json array but the data I'm being provided seems to require i have the price first?
var_dump(json_decode($resp, true));
$Data= json_decode($resp,true);
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
array) { ["status"]=> "SUCCESS" ["Date"]=> array(1) {
["2018-11-23"]=>
array() {
["115.5"]=>
array() {
[0]=>
array(46) {
["Price"]=> float(115.5)
["Date"]=> int(1543028400000)
}
}
["116.0"]=>
array() {
[0]=>
array() {
["Price"]=> float(116.0)
["Date"]=> int(1543028400000)
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
a partial snippet of the actual json:
{"symbol":"GLD","status":"SUCCESS","underlying":null,"strategy":"SINGLE","interval":null,"isDelayed":true,"isIndex":false,"interestRate":2.64581,"underlyingPrice":115.56,"volatility":29.0,"daysToExpiration":0.0,"callExpDateMap":{"2018-11-23:0":{"115.5":[{"putCall":"CALL","symbol":"GLD_112318C115.5","description":"GLD Nov 23 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.17,"ask":0.28,"last":0.22,"mark":0.23,"bidSize":132,"askSize":20,"lastSize":0,"highPrice":0.38,"lowPrice":0.13,"openPrice":0.0,"closePrice":0.53,"totalVolume":351,"tradeDate":null,"tradeTimeInLong":1542995987379,"quoteTimeInLong":1542995999544,"netChange":-0.31,"volatility":-999.0,"delta":1.0,"gamma":0.0,"theta":-0.008,"vega":0.0,"rho":0.003,"openInterest":2231,"timeValue":-0.05,"theoreticalOptionValue":-999.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-58.63,"markChange":-0.31,"markPercentChange":-57.69,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_112318C116","description":"GLD Nov 23 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.0,"ask":0.01,"last":0.01,"mark":0.01,"bidSize":0,"askSize":692,"lastSize":0,"highPrice":0.11,"lowPrice":0.01,"openPrice":0.0,"closePrice":0.26,"totalVolume":2167,"tradeDate":null,"tradeTimeInLong":1542995959548,"quoteTimeInLong":1542995984685,"netChange":-0.25,"volatility":0.0,"delta":0.0,"gamma":0.0,"theta":0.0,"vega":0.0,"rho":0.0,"openInterest":2786,"timeValue":0.01,"theoreticalOptionValue":0.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-96.21,"markChange":-0.26,"markPercentChange":-98.1,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-11-30:7":{"115.5":[{"putCall":"CALL","symbol":"GLD_113018C115.5","description":"GLD Nov 30 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.77,"ask":0.79,"last":0.76,"mark":0.78,"bidSize":22,"askSize":18,"lastSize":0,"highPrice":0.89,"lowPrice":0.73,"openPrice":0.0,"closePrice":0.94,"totalVolume":217,"tradeDate":null,"tradeTimeInLong":1542995943992,"quoteTimeInLong":1542995999810,"netChange":-0.18,"volatility":9.003,"delta":0.582,"gamma":0.253,"theta":-0.042,"vega":0.067,"rho":0.015,"openInterest":755,"timeValue":0.49,"theoreticalOptionValue":0.78,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-19.17,"markChange":-0.16,"markPercentChange":-17.05,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_113018C116","description":"GLD Nov 30 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.52,"ask":0.55,"last":0.53,"mark":0.54,"bidSize":920,"askSize":18,"lastSize":0,"highPrice":0.63,"lowPrice":0.49,"openPrice":0.0,"closePrice":0.69,"totalVolume":1278,"tradeDate":null,"tradeTimeInLong":1542995969283,"quoteTimeInLong":1542995999922,"netChange":-0.16,"volatility":9.165,"delta":0.454,"gamma":0.252,"theta":-0.043,"vega":0.068,"rho":0.011,"openInterest":2948,"timeValue":0.53,"theoreticalOptionValue":0.535,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-23.15,"markChange":-0.15,"markPercentChange":-22.43,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-12-07:14":{"115.5":[{"putCall":"CALL","symbol":"GLD_120718C115.5","description":"GLD Dec 7 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":1.07,"ask":1.1,"last":1.07,"mark":1.09,"bidSize":496,"askSize":22,"lastSize":0,"highPrice":1.16,"lowPrice":1.07,"openPrice":0.0,"closePrice":1.27,"totalVolume":3,"tradeDate":null,"tradeTimeInLong":1542988161634,"quoteTimeInLong":1542995999922,"netChange":-0.2,"volatility":9.532,"delta":0.569,"gamma":0.176,"theta":-0.034,"vega":0.092,"rho":0.027,"openInterest":214,"timeValue":0.8,"theoreticalOptionValue":1.085,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1544238000000,"d
php arrays json
can you provide the json you get please?
– Kurohige
Nov 23 '18 at 21:36
Is this a var_dump?
– ryantxr
Nov 23 '18 at 21:37
it is a var_dump
– quick_learner42
Nov 23 '18 at 21:38
var_dump(json_decode($resp, true)); $Data= json_decode($resp,true); foreach($Data as $jsonDataKey => $jsonDataValue){ foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){ echo "<hr>Price :".$jsonArrayValue['Price']; echo " Date:".$jsonArrayValue['Date']; } }
– quick_learner42
Nov 23 '18 at 21:39
Put the json in the question, not comments. Please.
– ryantxr
Nov 23 '18 at 21:39
|
show 5 more comments
I have read pages and pages and i'm lost on how to proceed. I am trying to extract the price from a json array but the data I'm being provided seems to require i have the price first?
var_dump(json_decode($resp, true));
$Data= json_decode($resp,true);
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
array) { ["status"]=> "SUCCESS" ["Date"]=> array(1) {
["2018-11-23"]=>
array() {
["115.5"]=>
array() {
[0]=>
array(46) {
["Price"]=> float(115.5)
["Date"]=> int(1543028400000)
}
}
["116.0"]=>
array() {
[0]=>
array() {
["Price"]=> float(116.0)
["Date"]=> int(1543028400000)
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
a partial snippet of the actual json:
{"symbol":"GLD","status":"SUCCESS","underlying":null,"strategy":"SINGLE","interval":null,"isDelayed":true,"isIndex":false,"interestRate":2.64581,"underlyingPrice":115.56,"volatility":29.0,"daysToExpiration":0.0,"callExpDateMap":{"2018-11-23:0":{"115.5":[{"putCall":"CALL","symbol":"GLD_112318C115.5","description":"GLD Nov 23 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.17,"ask":0.28,"last":0.22,"mark":0.23,"bidSize":132,"askSize":20,"lastSize":0,"highPrice":0.38,"lowPrice":0.13,"openPrice":0.0,"closePrice":0.53,"totalVolume":351,"tradeDate":null,"tradeTimeInLong":1542995987379,"quoteTimeInLong":1542995999544,"netChange":-0.31,"volatility":-999.0,"delta":1.0,"gamma":0.0,"theta":-0.008,"vega":0.0,"rho":0.003,"openInterest":2231,"timeValue":-0.05,"theoreticalOptionValue":-999.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-58.63,"markChange":-0.31,"markPercentChange":-57.69,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_112318C116","description":"GLD Nov 23 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.0,"ask":0.01,"last":0.01,"mark":0.01,"bidSize":0,"askSize":692,"lastSize":0,"highPrice":0.11,"lowPrice":0.01,"openPrice":0.0,"closePrice":0.26,"totalVolume":2167,"tradeDate":null,"tradeTimeInLong":1542995959548,"quoteTimeInLong":1542995984685,"netChange":-0.25,"volatility":0.0,"delta":0.0,"gamma":0.0,"theta":0.0,"vega":0.0,"rho":0.0,"openInterest":2786,"timeValue":0.01,"theoreticalOptionValue":0.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-96.21,"markChange":-0.26,"markPercentChange":-98.1,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-11-30:7":{"115.5":[{"putCall":"CALL","symbol":"GLD_113018C115.5","description":"GLD Nov 30 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.77,"ask":0.79,"last":0.76,"mark":0.78,"bidSize":22,"askSize":18,"lastSize":0,"highPrice":0.89,"lowPrice":0.73,"openPrice":0.0,"closePrice":0.94,"totalVolume":217,"tradeDate":null,"tradeTimeInLong":1542995943992,"quoteTimeInLong":1542995999810,"netChange":-0.18,"volatility":9.003,"delta":0.582,"gamma":0.253,"theta":-0.042,"vega":0.067,"rho":0.015,"openInterest":755,"timeValue":0.49,"theoreticalOptionValue":0.78,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-19.17,"markChange":-0.16,"markPercentChange":-17.05,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_113018C116","description":"GLD Nov 30 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.52,"ask":0.55,"last":0.53,"mark":0.54,"bidSize":920,"askSize":18,"lastSize":0,"highPrice":0.63,"lowPrice":0.49,"openPrice":0.0,"closePrice":0.69,"totalVolume":1278,"tradeDate":null,"tradeTimeInLong":1542995969283,"quoteTimeInLong":1542995999922,"netChange":-0.16,"volatility":9.165,"delta":0.454,"gamma":0.252,"theta":-0.043,"vega":0.068,"rho":0.011,"openInterest":2948,"timeValue":0.53,"theoreticalOptionValue":0.535,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-23.15,"markChange":-0.15,"markPercentChange":-22.43,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-12-07:14":{"115.5":[{"putCall":"CALL","symbol":"GLD_120718C115.5","description":"GLD Dec 7 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":1.07,"ask":1.1,"last":1.07,"mark":1.09,"bidSize":496,"askSize":22,"lastSize":0,"highPrice":1.16,"lowPrice":1.07,"openPrice":0.0,"closePrice":1.27,"totalVolume":3,"tradeDate":null,"tradeTimeInLong":1542988161634,"quoteTimeInLong":1542995999922,"netChange":-0.2,"volatility":9.532,"delta":0.569,"gamma":0.176,"theta":-0.034,"vega":0.092,"rho":0.027,"openInterest":214,"timeValue":0.8,"theoreticalOptionValue":1.085,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1544238000000,"d
php arrays json
I have read pages and pages and i'm lost on how to proceed. I am trying to extract the price from a json array but the data I'm being provided seems to require i have the price first?
var_dump(json_decode($resp, true));
$Data= json_decode($resp,true);
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
array) { ["status"]=> "SUCCESS" ["Date"]=> array(1) {
["2018-11-23"]=>
array() {
["115.5"]=>
array() {
[0]=>
array(46) {
["Price"]=> float(115.5)
["Date"]=> int(1543028400000)
}
}
["116.0"]=>
array() {
[0]=>
array() {
["Price"]=> float(116.0)
["Date"]=> int(1543028400000)
foreach($Data as $jsonDataKey => $jsonDataValue){
foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){
echo "<hr>Price :".$jsonArrayValue['Price'];
echo " Date:".$jsonArrayValue['Date'];
}
}
a partial snippet of the actual json:
{"symbol":"GLD","status":"SUCCESS","underlying":null,"strategy":"SINGLE","interval":null,"isDelayed":true,"isIndex":false,"interestRate":2.64581,"underlyingPrice":115.56,"volatility":29.0,"daysToExpiration":0.0,"callExpDateMap":{"2018-11-23:0":{"115.5":[{"putCall":"CALL","symbol":"GLD_112318C115.5","description":"GLD Nov 23 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.17,"ask":0.28,"last":0.22,"mark":0.23,"bidSize":132,"askSize":20,"lastSize":0,"highPrice":0.38,"lowPrice":0.13,"openPrice":0.0,"closePrice":0.53,"totalVolume":351,"tradeDate":null,"tradeTimeInLong":1542995987379,"quoteTimeInLong":1542995999544,"netChange":-0.31,"volatility":-999.0,"delta":1.0,"gamma":0.0,"theta":-0.008,"vega":0.0,"rho":0.003,"openInterest":2231,"timeValue":-0.05,"theoreticalOptionValue":-999.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-58.63,"markChange":-0.31,"markPercentChange":-57.69,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_112318C116","description":"GLD Nov 23 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.0,"ask":0.01,"last":0.01,"mark":0.01,"bidSize":0,"askSize":692,"lastSize":0,"highPrice":0.11,"lowPrice":0.01,"openPrice":0.0,"closePrice":0.26,"totalVolume":2167,"tradeDate":null,"tradeTimeInLong":1542995959548,"quoteTimeInLong":1542995984685,"netChange":-0.25,"volatility":0.0,"delta":0.0,"gamma":0.0,"theta":0.0,"vega":0.0,"rho":0.0,"openInterest":2786,"timeValue":0.01,"theoreticalOptionValue":0.0,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543028400000,"daysToExpiration":0,"expirationType":"S","lastTradingDay":1542949200000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-96.21,"markChange":-0.26,"markPercentChange":-98.1,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-11-30:7":{"115.5":[{"putCall":"CALL","symbol":"GLD_113018C115.5","description":"GLD Nov 30 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":0.77,"ask":0.79,"last":0.76,"mark":0.78,"bidSize":22,"askSize":18,"lastSize":0,"highPrice":0.89,"lowPrice":0.73,"openPrice":0.0,"closePrice":0.94,"totalVolume":217,"tradeDate":null,"tradeTimeInLong":1542995943992,"quoteTimeInLong":1542995999810,"netChange":-0.18,"volatility":9.003,"delta":0.582,"gamma":0.253,"theta":-0.042,"vega":0.067,"rho":0.015,"openInterest":755,"timeValue":0.49,"theoreticalOptionValue":0.78,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-19.17,"markChange":-0.16,"markPercentChange":-17.05,"inTheMoney":true,"nonStandard":false,"mini":false}],"116.0":[{"putCall":"CALL","symbol":"GLD_113018C116","description":"GLD Nov 30 2018 116 Call (Weekly)","exchangeName":"OPR","bid":0.52,"ask":0.55,"last":0.53,"mark":0.54,"bidSize":920,"askSize":18,"lastSize":0,"highPrice":0.63,"lowPrice":0.49,"openPrice":0.0,"closePrice":0.69,"totalVolume":1278,"tradeDate":null,"tradeTimeInLong":1542995969283,"quoteTimeInLong":1542995999922,"netChange":-0.16,"volatility":9.165,"delta":0.454,"gamma":0.252,"theta":-0.043,"vega":0.068,"rho":0.011,"openInterest":2948,"timeValue":0.53,"theoreticalOptionValue":0.535,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":116.0,"expirationDate":1543633200000,"daysToExpiration":7,"expirationType":"S","lastTradingDay":1543554000000,"multiplier":100.0,"settlementType":" ","deliverableNote":"","isIndexOption":null,"percentChange":-23.15,"markChange":-0.15,"markPercentChange":-22.43,"inTheMoney":false,"nonStandard":false,"mini":false}]},"2018-12-07:14":{"115.5":[{"putCall":"CALL","symbol":"GLD_120718C115.5","description":"GLD Dec 7 2018 115.5 Call (Weekly)","exchangeName":"OPR","bid":1.07,"ask":1.1,"last":1.07,"mark":1.09,"bidSize":496,"askSize":22,"lastSize":0,"highPrice":1.16,"lowPrice":1.07,"openPrice":0.0,"closePrice":1.27,"totalVolume":3,"tradeDate":null,"tradeTimeInLong":1542988161634,"quoteTimeInLong":1542995999922,"netChange":-0.2,"volatility":9.532,"delta":0.569,"gamma":0.176,"theta":-0.034,"vega":0.092,"rho":0.027,"openInterest":214,"timeValue":0.8,"theoreticalOptionValue":1.085,"theoreticalVolatility":29.0,"optionDeliverablesList":null,"strikePrice":115.5,"expirationDate":1544238000000,"d
php arrays json
php arrays json
edited Nov 23 '18 at 21:44
quick_learner42
asked Nov 23 '18 at 21:32
quick_learner42quick_learner42
1411311
1411311
can you provide the json you get please?
– Kurohige
Nov 23 '18 at 21:36
Is this a var_dump?
– ryantxr
Nov 23 '18 at 21:37
it is a var_dump
– quick_learner42
Nov 23 '18 at 21:38
var_dump(json_decode($resp, true)); $Data= json_decode($resp,true); foreach($Data as $jsonDataKey => $jsonDataValue){ foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){ echo "<hr>Price :".$jsonArrayValue['Price']; echo " Date:".$jsonArrayValue['Date']; } }
– quick_learner42
Nov 23 '18 at 21:39
Put the json in the question, not comments. Please.
– ryantxr
Nov 23 '18 at 21:39
|
show 5 more comments
can you provide the json you get please?
– Kurohige
Nov 23 '18 at 21:36
Is this a var_dump?
– ryantxr
Nov 23 '18 at 21:37
it is a var_dump
– quick_learner42
Nov 23 '18 at 21:38
var_dump(json_decode($resp, true)); $Data= json_decode($resp,true); foreach($Data as $jsonDataKey => $jsonDataValue){ foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){ echo "<hr>Price :".$jsonArrayValue['Price']; echo " Date:".$jsonArrayValue['Date']; } }
– quick_learner42
Nov 23 '18 at 21:39
Put the json in the question, not comments. Please.
– ryantxr
Nov 23 '18 at 21:39
can you provide the json you get please?
– Kurohige
Nov 23 '18 at 21:36
can you provide the json you get please?
– Kurohige
Nov 23 '18 at 21:36
Is this a var_dump?
– ryantxr
Nov 23 '18 at 21:37
Is this a var_dump?
– ryantxr
Nov 23 '18 at 21:37
it is a var_dump
– quick_learner42
Nov 23 '18 at 21:38
it is a var_dump
– quick_learner42
Nov 23 '18 at 21:38
var_dump(json_decode($resp, true)); $Data= json_decode($resp,true); foreach($Data as $jsonDataKey => $jsonDataValue){ foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){ echo "<hr>Price :".$jsonArrayValue['Price']; echo " Date:".$jsonArrayValue['Date']; } }
– quick_learner42
Nov 23 '18 at 21:39
var_dump(json_decode($resp, true)); $Data= json_decode($resp,true); foreach($Data as $jsonDataKey => $jsonDataValue){ foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){ echo "<hr>Price :".$jsonArrayValue['Price']; echo " Date:".$jsonArrayValue['Date']; } }
– quick_learner42
Nov 23 '18 at 21:39
Put the json in the question, not comments. Please.
– ryantxr
Nov 23 '18 at 21:39
Put the json in the question, not comments. Please.
– ryantxr
Nov 23 '18 at 21:39
|
show 5 more comments
2 Answers
2
active
oldest
votes
Looking at the data, the following code should work.
$data = json_decode($jsonString, true);
$history = $data['callExpDateMap'];
foreach( $history as $date => $entry ) {
foreach ( $entry as $key => $row ) {
$strikePrice = $row['strikePrice'];
echo "Date : " . $date . "n";
echo "Strike price : " . $strikePrice . "n";
}
}
This displayed the date but not the strikePrice
– quick_learner42
Nov 23 '18 at 23:19
foreach( $history as $date => $entry ) { foreach ( $entry as $key => $row ) { $strikePrice = $row['strikePrice']; echo "<br>Date : " . $date . "n"; echo "<br>Strike price : " .$key. "<br><br>n"; } }
– quick_learner42
Nov 23 '18 at 23:23
add a comment |
There is no "Price" key in the JSON you've supplied. However, I can see "symbol", "status", "volatility" etc. If Price is on the same level as these keys, you would access this way:
foreach ($data as $value) {
echo $value["Price"];
}
If Price were a level deeper, you'd access via the first level key this way:
foreach ($data as $value) {
echo $value["firstLevel"]["Price"];
}
And so on. There are a few ways to visualise the JSON, try pasting it here https://jsonformatter.curiousconcept.com/ and you should be able to easily find where "Price" lives, but I suspect it's a top level key.
It's actually "strikePrice"
– quick_learner42
Nov 23 '18 at 23:19
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453162%2fjson-response-array-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Looking at the data, the following code should work.
$data = json_decode($jsonString, true);
$history = $data['callExpDateMap'];
foreach( $history as $date => $entry ) {
foreach ( $entry as $key => $row ) {
$strikePrice = $row['strikePrice'];
echo "Date : " . $date . "n";
echo "Strike price : " . $strikePrice . "n";
}
}
This displayed the date but not the strikePrice
– quick_learner42
Nov 23 '18 at 23:19
foreach( $history as $date => $entry ) { foreach ( $entry as $key => $row ) { $strikePrice = $row['strikePrice']; echo "<br>Date : " . $date . "n"; echo "<br>Strike price : " .$key. "<br><br>n"; } }
– quick_learner42
Nov 23 '18 at 23:23
add a comment |
Looking at the data, the following code should work.
$data = json_decode($jsonString, true);
$history = $data['callExpDateMap'];
foreach( $history as $date => $entry ) {
foreach ( $entry as $key => $row ) {
$strikePrice = $row['strikePrice'];
echo "Date : " . $date . "n";
echo "Strike price : " . $strikePrice . "n";
}
}
This displayed the date but not the strikePrice
– quick_learner42
Nov 23 '18 at 23:19
foreach( $history as $date => $entry ) { foreach ( $entry as $key => $row ) { $strikePrice = $row['strikePrice']; echo "<br>Date : " . $date . "n"; echo "<br>Strike price : " .$key. "<br><br>n"; } }
– quick_learner42
Nov 23 '18 at 23:23
add a comment |
Looking at the data, the following code should work.
$data = json_decode($jsonString, true);
$history = $data['callExpDateMap'];
foreach( $history as $date => $entry ) {
foreach ( $entry as $key => $row ) {
$strikePrice = $row['strikePrice'];
echo "Date : " . $date . "n";
echo "Strike price : " . $strikePrice . "n";
}
}
Looking at the data, the following code should work.
$data = json_decode($jsonString, true);
$history = $data['callExpDateMap'];
foreach( $history as $date => $entry ) {
foreach ( $entry as $key => $row ) {
$strikePrice = $row['strikePrice'];
echo "Date : " . $date . "n";
echo "Strike price : " . $strikePrice . "n";
}
}
answered Nov 23 '18 at 22:13
ryantxrryantxr
2,6741520
2,6741520
This displayed the date but not the strikePrice
– quick_learner42
Nov 23 '18 at 23:19
foreach( $history as $date => $entry ) { foreach ( $entry as $key => $row ) { $strikePrice = $row['strikePrice']; echo "<br>Date : " . $date . "n"; echo "<br>Strike price : " .$key. "<br><br>n"; } }
– quick_learner42
Nov 23 '18 at 23:23
add a comment |
This displayed the date but not the strikePrice
– quick_learner42
Nov 23 '18 at 23:19
foreach( $history as $date => $entry ) { foreach ( $entry as $key => $row ) { $strikePrice = $row['strikePrice']; echo "<br>Date : " . $date . "n"; echo "<br>Strike price : " .$key. "<br><br>n"; } }
– quick_learner42
Nov 23 '18 at 23:23
This displayed the date but not the strikePrice
– quick_learner42
Nov 23 '18 at 23:19
This displayed the date but not the strikePrice
– quick_learner42
Nov 23 '18 at 23:19
foreach( $history as $date => $entry ) { foreach ( $entry as $key => $row ) { $strikePrice = $row['strikePrice']; echo "<br>Date : " . $date . "n"; echo "<br>Strike price : " .$key. "<br><br>n"; } }
– quick_learner42
Nov 23 '18 at 23:23
foreach( $history as $date => $entry ) { foreach ( $entry as $key => $row ) { $strikePrice = $row['strikePrice']; echo "<br>Date : " . $date . "n"; echo "<br>Strike price : " .$key. "<br><br>n"; } }
– quick_learner42
Nov 23 '18 at 23:23
add a comment |
There is no "Price" key in the JSON you've supplied. However, I can see "symbol", "status", "volatility" etc. If Price is on the same level as these keys, you would access this way:
foreach ($data as $value) {
echo $value["Price"];
}
If Price were a level deeper, you'd access via the first level key this way:
foreach ($data as $value) {
echo $value["firstLevel"]["Price"];
}
And so on. There are a few ways to visualise the JSON, try pasting it here https://jsonformatter.curiousconcept.com/ and you should be able to easily find where "Price" lives, but I suspect it's a top level key.
It's actually "strikePrice"
– quick_learner42
Nov 23 '18 at 23:19
add a comment |
There is no "Price" key in the JSON you've supplied. However, I can see "symbol", "status", "volatility" etc. If Price is on the same level as these keys, you would access this way:
foreach ($data as $value) {
echo $value["Price"];
}
If Price were a level deeper, you'd access via the first level key this way:
foreach ($data as $value) {
echo $value["firstLevel"]["Price"];
}
And so on. There are a few ways to visualise the JSON, try pasting it here https://jsonformatter.curiousconcept.com/ and you should be able to easily find where "Price" lives, but I suspect it's a top level key.
It's actually "strikePrice"
– quick_learner42
Nov 23 '18 at 23:19
add a comment |
There is no "Price" key in the JSON you've supplied. However, I can see "symbol", "status", "volatility" etc. If Price is on the same level as these keys, you would access this way:
foreach ($data as $value) {
echo $value["Price"];
}
If Price were a level deeper, you'd access via the first level key this way:
foreach ($data as $value) {
echo $value["firstLevel"]["Price"];
}
And so on. There are a few ways to visualise the JSON, try pasting it here https://jsonformatter.curiousconcept.com/ and you should be able to easily find where "Price" lives, but I suspect it's a top level key.
There is no "Price" key in the JSON you've supplied. However, I can see "symbol", "status", "volatility" etc. If Price is on the same level as these keys, you would access this way:
foreach ($data as $value) {
echo $value["Price"];
}
If Price were a level deeper, you'd access via the first level key this way:
foreach ($data as $value) {
echo $value["firstLevel"]["Price"];
}
And so on. There are a few ways to visualise the JSON, try pasting it here https://jsonformatter.curiousconcept.com/ and you should be able to easily find where "Price" lives, but I suspect it's a top level key.
answered Nov 23 '18 at 21:58
Nick DawesNick Dawes
919
919
It's actually "strikePrice"
– quick_learner42
Nov 23 '18 at 23:19
add a comment |
It's actually "strikePrice"
– quick_learner42
Nov 23 '18 at 23:19
It's actually "strikePrice"
– quick_learner42
Nov 23 '18 at 23:19
It's actually "strikePrice"
– quick_learner42
Nov 23 '18 at 23:19
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453162%2fjson-response-array-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
can you provide the json you get please?
– Kurohige
Nov 23 '18 at 21:36
Is this a var_dump?
– ryantxr
Nov 23 '18 at 21:37
it is a var_dump
– quick_learner42
Nov 23 '18 at 21:38
var_dump(json_decode($resp, true)); $Data= json_decode($resp,true); foreach($Data as $jsonDataKey => $jsonDataValue){ foreach($jsonDataValue as $jsonArrayKey => $jsonArrayValue){ echo "<hr>Price :".$jsonArrayValue['Price']; echo " Date:".$jsonArrayValue['Date']; } }
– quick_learner42
Nov 23 '18 at 21:39
Put the json in the question, not comments. Please.
– ryantxr
Nov 23 '18 at 21:39