如何将响应转换为适当的表单?

时间:2018-06-09 15:43:59

标签: php request

我使用Binance API。 PHP函数获取url:

的文件内容
https://api.binance.com/api/v1/klines?symbol=BTCUSDT&interval=4h&limit=1

我收到了这样的答复:

[[1528545600000,"7635.01000000","7650.00000000","7566.00000000","7621.15000000","3246.04484200",1528559999999,"24674635.12120312",57351,"1932.28202000","14685353.70584041","0"]]

如何获得第二个值? (7635.01000000)

1 个答案:

答案 0 :(得分:0)

如果你想获得第二个值,请使用:

$receivedData = '[[1528545600000,"7635.01000000","7650.00000000","7566.00000000","7621.15000000","3246.04484200",1528559999999,"24674635.12120312",57351,"1932.28202000","14685353.70584041","0"]]';

$jsonDecodeData = json_decode($receivedData); 

$secondValue = jsonDecodeData[0][1];

echo $secondValue; //7635.01000000