[英]Accessing array with nested objects
I have an api wrapper i am using that returns something like this 我有一个正在使用的api包装器,返回的内容是这样的
object(stdClass)#7 (1) {
[0]=>
object(stdClass)#6 (2) {
["contactId"]=>
string(2) "nV"
["email"]=>
string(31) "email@domain.com"
}
}
how do i access the email part with PHP 我如何使用PHP访问电子邮件部分
Cast your API returned data to an array. 将您的API返回的数据转换为数组。
For example you are saving API returned data in $result
variable. 例如,您将API返回的数据保存在$result
变量中。 Cast it to an array. 将其转换为数组。
$arrayResult = (array) $result;
echo $arrayResult[0]->email;
Try this. 尝试这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.