我有这个数组作为json格式的输出。
Array
(
[totalSize] => 1
[done] => 1
[records] => Array
(
[0] => Array
(
[attributes] => Array
(
[type] => Emp
[url] => /services/data/v20.0/sobjects/AG
)
[Name] => John Doe
[Company__r] => Array
(
[attributes] => Array
(
[type] => Comp
[url] => /services/data/v20.0/AZ
)
[Name] => LINEA
)
)
)
)
我能够使用以下代码访问值为John Doe的Name
属性。
foreach ($result['records'] as $record) {
print_r($record['Name']);
print_r("<br>");
}
但我无法访问价值为&#34; Linea&#34;的Name
属性。我该如何访问最里面的值。 ?
答案 0 :(得分:0)
因为它在'Company__r'
数组中,所以它应该是这样的。
foreach ($result['records'] as $record) {
echo $record['Name']; //John Doe
echo $record['Company__r']['Name']; //LINEA
}