尝试访问此数组中的对象。 我跟着
无论我尝试什么,我都无法从阵列中得到我需要的东西。
唯一可行的是
echo $response->TotalResults;
这给了我18的价值。很棒但是当我尝试
时 echo $response->Call[0]->ToNumber->_;
或
echo $response->Call->CallRecord->Result;
返回空白
我尝试过另一个帖子的foreach循环:
foreach($responses->TotalResults as $value){
foreach($value->Call as $obj){
echo $obj->FromNumber;
}
echo $value->name;
}
什么都不返回。我真的没有找到任何有助于PHP网站的东西,这将有助于指导我如何从这种数组中检索数据。下面是示例数据数组。
object(stdClass)#8 (2) {
["TotalResults"]=> int(18)
["Call"]=> array(18) {
[0]=>
object(stdClass)#9 (12) {
["FromNumber"]=>
string(11) "17575551211"
["ToNumber"]=>
object(stdClass)#10 (1) {
["_"]=>
string(11) "17575554039"
}
["State"]=>
string(8) "FINISHED"
["BatchId"]=>
int(33236)
["BroadcastId"]=>
int(1069425001)
["ContactId"]=>
float(836743)
["Inbound"]=>
bool(false)
["Created"]=>
string(20) "2013-08-09T15:24:11Z"
["Modified"]=>
string(20) "2013-08-11T13:16:54Z"
["FinalResult"]=>
string(2) "LA"
["id"]=>
float(1001389)
["CallRecord"]=>
array(2) {
[0]=>
object(stdClass)#11 (7) {
["Result"]=>
string(2) "LA"
["FinishTime"]=>
string(20) "2013-08-11T13:16:51Z"
["BilledAmount"]=>
float(1.6667)
["QuestionResponse"]=>
object(stdClass)#12 (2) {
["Question"]=>
string(4) "Q1R1"
["Response"]=>
string(7) "Confirm"
}
["id"]=>
float(572965)
["AnswerTime"]=>
string(20) "2013-08-11T13:16:22Z"
["Duration"]=>
int(29)
}
[1]=>
object(stdClass)#13 (6) {
["Result"]=>
string(6) "NO_ANS"
["FinishTime"]=>
string(20) "2013-08-11T13:01:05Z"
["BilledAmount"]=>
float(0)
["id"]=>
float(57296503001)
["OriginateTime"]=>
string(20) "2013-08-11T13:00:02Z"
["Duration"]=>
int(0)
}
}
}
[1]=>
object(stdClass)#14 (12) {
["FromNumber"]=>
string(11) "17575557998"
["ToNumber"]=>
object(stdClass)#15 (1) {
["_"]=>
string(11) "17575557255"
}
["State"]=>
string(8) "FINISHED"
["BatchId"]=>
int(332369)
["BroadcastId"]=>
int(1069425)
["ContactId"]=>
float(83674367)
["Inbound"]=>
bool(false)
["Created"]=>
string(20) "2013-08-09T15:24:11Z"
["Modified"]=>
string(20) "2013-08-11T13:03:17Z"
["FinalResult"]=>
string(2) "LA"
["id"]=>
float(100138916)
["CallRecord"]=>
object(stdClass)#16 (6) {
["Result"]=>
string(2) "LA"
["FinishTime"]=>
string(20) "2013-08-11T13:03:13Z"
["BilledAmount"]=>
float(5.0001)
["id"]=>
float(57296546)
["AnswerTime"]=>
string(20) "2013-08-11T13:00:35Z"
["Duration"]=>
int(158)
}
}
[2]=>
object(stdClass)#17 (12) {
["FromNumber"]=>
string(11) "17575557998"
["ToNumber"]=>
object(stdClass)#18 (1) {
["_"]=>
string(11) "17575552158"
}
["State"]=>
string(8) "FINISHED"
["BatchId"]=>
int(332369)
["BroadcastId"]=>
int(106942)
["ContactId"]=>
float(83674)
["Inbound"]=>
bool(false)
["Created"]=>
string(20) "2013-08-09T15:24:11Z"
["Modified"]=>
string(20) "2013-08-11T13:03:15Z"
["FinalResult"]=>
string(2) "LA"
["id"]=>
float(100138)
}
}
}
有关如何访问阵列的任何帮助都会很棒。 此致