php - 从多维度数组中读取数据
问题描述
我对 PHP 很陌生,并尝试为自己的小项目学习。而现在我正在挣扎。
目标:
- 从https://www.etoro.com/api/streams/v2/streams/user-trades/lee88eng导入数据
- 将前 10 个条目的“RootData:Rate, Leverage, Direction // Symbol: displayname”保存到变量中
问题:我已经开始尝试读取 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";
?>```
解决方案
推荐阅读
- javascript - 倒计时状态栏
- performance - 从 paypalobjects.com 加载的 Noop.js 失败/非常慢
- node.js - 是否可以在 ReactJS 中使用服务器 VM 上设置的环境变量?
- reactjs - 将索引数据库与动态缓存数据同步并在联机时更新状态
- c++ - 修改后的文件出现意外的 fgets 行为
- sass - Hugo:从 GitHub 导入 sass / 代码的最佳方式?
- asp.net-core - Entity FrameWork Core 不显示查询返回的值
- performance - Dart - 异步与同步性能注意事项
- .net-core - .Net Core 中的文档审批工作流程(无 SharePoint)
- python - TypeError:“NoneType”对象不可迭代,边界检测 OpenCV