Fetching specific data in array and assign a variable? php-json

Fetching specific data in array and assign a variable? php-json
0.0 0

#1

{
“Meta Data”: {
“1. Information”: “Intraday (5min) prices and volumes”,
“2. Symbol”: “MSFT”,
“3. Last Refreshed”: “2018-02-02 16:00:00”,
“4. Interval”: “5min”,
“5. Output Size”: “Compact”,
“6. Time Zone”: “US/Eastern”
},
“Time Series (5min)”: {
“2018-02-02 16:00:00”: {
“1. open”: “92.0500”,
“2. high”: “92.1400”,
“3. low”: “91.5000”,
“4. close”: “91.7800”,
“5. volume”: “6200291”
},
“2018-02-02 15:55:00”: {
“1. open”: “92.0150”,
“2. high”: “92.3150”,
“3. low”: “92.0100”,
“4. close”: “92.0500”,
“5. volume”: “653474”
},
“2018-02-02 15:50:00”: {
“1. open”: “92.3100”,
“2. high”: “92.3300”,
“3. low”: “91.9400”,
“4. close”: “92.0350”,
“5. volume”: “732710”
},
“2018-02-02 15:45:00”: {
“1. open”: “92.3600”,
“2. high”: “92.3600”,
“3. low”: “92.1500”,
“4. close”: “92.3100”,
“5. volume”: “471366”
},
“2018-02-02 15:40:00”: {
“1. open”: “92.2500”,
“2. high”: “92.4352”,
“3. low”: “92.1500”,
“4. close”: “92.3700”,
“5. volume”: “434716”
},

Hello im working on a project in php JSON, data from an api

How do I fetch latest 5 [‘1. open’]
values in my Json array and assign $a $b $c $d $e
to five different closest to now date.

Ive tried different methods I used foreach to get all dates and data in an foreach loop.
And I tried make formula, but it fails cause I dont use date right
The formula start -5 minutes and loop to 0 but it doesnt work if clock is
10:01:00 thus becoming 10:-4:00
\
I need the data to be like a-e $ variables for a chart.
Ani input is welcome
its a bit complex but I dont know where to ask and option is to remapp
the json response to a chart friendly format but i have no clue how to do that.
thanks


#2

Why don’t you show us what code you have tried and explain what you think it should do and then what you get instead?


#3

I am not sure if i have undestanded your question but i think that you want to get only the data from the “Time Series (5min)”.
I think this can help you:

First decode your json .
$data=json_decode($response);

Than specify what you want for example
$data2=$data->Time Series (5min)

Something like that , i use it on an application