php - 数组无法获取变量 PHP
问题描述
这可能很简单,但由于某种原因,我无法让我的代码回显变量。抱歉,我是 php 新手。
$file ="https://creator.zoho.com/api/json/los/view/All_Borrowers?
authtoken=xxx&raw=true";
$bors = file_get_contents($file);
$array = json_decode($bors);
$vars = get_object_vars($array);
退货
Array
(
[Borrowers] => Array
(
[0] => stdClass Object
(
[Full_Name] => Steve Smith
[Email] => fsgfsz@gmail.com
[Address] => Granby Ct., Aurora, CO, 80012
[Position] => Borrower
[ID] => 1159827000004784102
[Mobile] => +13035550050
[Application] => Application 1 - 1159827000004784096
)
[1] => stdClass Object
(
[Full_Name] => Stacy H Sanchez
[Email] => dfd@gmail.com
[Address] => Granby, 80012
[Position] => Co-Borrower
[ID] => 1159827000004784108
[Mobile] => +13035550957
[Application] => Application 1 - 1159827000004784096
)
)
)
我在用着:
echo $vars["Borrowers"][0]["Full_Name"];
但它抛出一个错误。不知道我哪里出错了。
解决方案
Full_name 是对象属性,而不是数组索引
echo $vars["Borrowers"][0]->Full_Name;
推荐阅读
- python - Markowitz 前沿返回相同的波动率 400 倍
- node.js - 如何避免代码异味“参数过多”
- pyspark - 将 Spark 中的数据提取到 AWS EMR 中的 Hive
- r - 过滤除某些特定单词外所有字符长度相同的单词
- sql - 列出唯一的用户,尽管他们在不同国家/地区多次出现
- api - 使用 gitlab api 创建图形和表格
- r - 如何根据来自 renderUI 的输入对数据进行子集化
- c# - 在运行时访问 Unity 包版本
- node.js - node.js 和 mongodb 在现有数据库中按顺序递增 _id
- java - 为什么即使if语句为真,它也会重定向到假设在else子句中发生的页面(我觉得)