Answer the question
In order to leave comments, you need to log in
How to extract data from json multidimensional array?
Hello! Please help, I need to extract data from json array. I need to get the value of the rate
I'm trying to do this, but it doesn't work
$arr = json_decode($open_orders, true);
$open_orders = $arr[0]['rate'];
[
{
"id": "QPYRgfwiB9",
"state": "opened",
"type": "buy",
"open_amount": 0.001,
"amount": 0.001,
"rate": 0.001,
"price": 0.000001,
"timestamp": 1498215757
},
...
]
Answer the question
In order to leave comments, you need to log in
Maybe you messed up something with variable names or made an error in json because of which it is equal to Null. everything shows fine for me:
<?php
$json = '
[{
"id": "QPYRgfwiB9",
"state": "opened",
"type": "buy",
"open_amount": 0.001,
"amount": 0.001,
"rate": 0.001,
"price": 0.000001,
"timestamp": 1498215757
},
{
"id": "QPYRgfwiB9",
"state": "opened",
"type": "buy",
"open_amount": 0.001,
"amount": 0.001,
"rate": 0.002,
"price": 0.000001,
"timestamp": 1498215757
}]';
$arr = json_decode($json, true);
echo $arr[0]['rate'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question