从数组PHP中读取对象值

时间:2017-04-26 18:08:51

标签: php salesforce

我正在尝试从php

中的以下查询结果中读取 Name
$queryResult= 
QueryResult Object ( 
    [records] => Array ( 
                [0] => stdClass Object ( 
                      [Id] => [Account] => stdClass Object ( 
                                        [Id] => [Name] => Smith Joyn Household 
                                         ) 
                      [Amount] => 150 
                      ) 
      )
)

我用于打印值的内容。

foreach ($queryResult->records as $record) {
   echo $record->Amount; // prints 150
   echo $record->Account->Name; // this doesn't
}

1 个答案:

答案 0 :(得分:-1)

感谢大家的帮助。以下工作;

echo $ record-> Account-> Name;