首页 > 解决方案 > 从多维度数组中读取数据

问题描述

我对 PHP 很陌生,并尝试为自己的小项目学习。而现在我正在挣扎。

目标:

问题:我已经开始尝试读取 RootData:Rate。见附件。但是出现错误。

警告:array_values() 期望参数 1 为数组,在第 12 行的stocks_scanner/etoro.php 中给出空值

有任何想法吗?:-( 提前非常感谢!<3

<?php

//stock 
$stockurl = 'https://www.etoro.com/api/streams/v2/streams/user-trades/lee88eng'; // path to your JSON file
$stockdata = file_get_contents($stockurl); // put the contents of the file into a variable

$stockcharacters = json_decode($stockdata, true); // decode the JSON feed

//Array zu Variable
$timeseries = array_values($stockcharacters)['rootData'];
$close = array_values($timeseries)[0][1];
echo  "close is $close";

     
?>```


 

标签: phpjson

解决方案


推荐阅读