这可能非常简单,但是由于某些原因,我无法获取代码来回显变量。对不起,我是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"];
,但抛出错误。不确定我哪里出错了。
答案 0 :(得分:1)
全名是对象属性,而不是数组索引
echo $vars["Borrowers"][0]->Full_Name;