I have a php class that grabs data from a json api call. I want to grab a specific value from a specific key, however the key is based on date and time, so it is always changing. I thought about creating a variable that uses Date() and matches their format, but I am hoping there is an easier way.
Here is the json
{
"Meta Data": {
"1. Information": "Intraday (1min) prices and volumes",
"2. Symbol": "UGA",
"3. Last Refreshed": "2017-06-20 11:47:00",
"4. Interval": "1min",
"5. Output Size": "Compact",
"6. Time Zone": "US/Eastern"
},
"Time Series (1min)": {
"2017-06-20 11:47:00": {
"1. open": "22.7500",
"2. high": "22.7500",
"3. low": "22.7500",
"4. close": "22.7500",
"5. volume": "200"
},
"2017-06-20 10:38:00": {
"1. open": "22.6000",
"2. high": "22.6000",
"3. low": "22.6000",
"4. close": "22.6000",
"5. volume": "300"
}
}
This is what my php looks like
$result = curl_exec($ch);
$json = json_decode($result, true);
echo $json["Time Series (1min)"]["2017-06-20 11:47:00"]["1. open"];