以下是来自Salesforce的以下返回查询。如果我尝试$form_information[0]->Program_Type__c;
,我会收到以下错误:
不能使用stdClass类型的对象作为数组
下面是我的下面一个包含对象的数组?我的问题是如何从我的对象中提取Program_type__c和Campus_ID__c并将其保存到变量中?
print_r($form_information);
Array
(
[totalSize] => 1
[done] => 1
[records] => Array
(
[0] => stdClass Object
(
[attributes] => stdClass Object
(
[type] => Program_Instance__c
[url] => /services/data/v22.0/sobjects/Program_Instance__c/a0Ji0000001EUk9EAG
)
[Program_Type__c] => Field Science
[Program_Sub_type__c] =>
[Campus_ID__c] => a03i0000002DDBjAAO
)
)
)
array(3) {
["totalSize"]=>
int(1)
["done"]=>
bool(true)
["records"]=>
array(1) {
[0]=>
object(stdClass)#21 (4) {
["attributes"]=>
object(stdClass)#22 (2) {
["type"]=>
string(19) "Program_Instance__c"
["url"]=>
string(68) "/services/data/v22.0/sobjects/Program_Instance__c/a0Ji0000001EUk9EAG"
}
["Program_Type__c"]=>
string(13) "Field Science"
["Program_Sub_type__c"]=>
NULL
["Campus_ID__c"]=>
string(18) "a03i0000002DDBjAAO"
}
}
}
答案 0 :(得分:5)
您没有正确遍历该对象。
我相信你正在追求更像:
$form_information['records'][0]->Program_Type__c
但是,我建议您阅读有关PHP Arrays和Object Properties的介绍。
答案 1 :(得分:2)
尝试$ form_information ['records'] [0] - > Program_Type__c;