我想从[0]和[1]
中的两个货件打印[UpdateDescription]的值以下是发送的请求
$auth_call = $soapClient->TrackShipments($params);
货件编号在$ params数组中发送
响应低于
stdClass Object
(
[Transaction] => stdClass Object
(
[Reference1] =>
[Reference2] =>
[Reference3] =>
[Reference4] =>
[Reference5] =>
)
[Notifications] => stdClass Object
(
)
[HasErrors] =>
[TrackingResults] => stdClass Object
(
[KeyValueOfstringArrayOfTrackingResultmFAkxlpY] => Array
(
[0] => stdClass Object
(
[Key] => 52398174132
[Value] => stdClass Object
(
[TrackingResult] => stdClass Object
(
[WaybillNumber] => 52398174132
[UpdateCode] => SH005
[UpdateDescription] => Delivered
[UpdateDateTime] => 2016-09-26T14:45:00
[UpdateLocation] => New York
[Comments] => Maz
[ProblemCode] =>
)
)
)
[1] => stdClass Object
(
[Key] => 43559827323
[Value] => stdClass Object
(
[TrackingResult] => stdClass Object
(
[WaybillNumber] => 43559827323
[UpdateCode] => SH008
[UpdateDescription] => Shipment on Hold
[UpdateDateTime] => 2016-09-28T10:18:00
[UpdateLocation] => New York
[Comments] => Na
[ProblemCode] =>
)
)
)
)
)
)
我目前能够使用以下内容打印[UpdateDescription]的值,当响应中没有[0]和[1]只有1次出货时
$description = $auth_call->TrackingResults-KeyValueOfstringArrayOfTrackingResultmFAkxlpY->Value->TrackingResult-UpdateDescription;
print_r($description);
答案 0 :(得分:0)
尝试使用foreach
- 循环:
foreach($auth_call->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY as $tracking_result) {
print_r ($tracking_result->Value->TrackingResult->UpdateDescription);
}
答案 1 :(得分:-2)
你试试吗
$description = $auth_call->TrackingResults-KeyValueOfstringArrayOfTrackingResultmFAkxlpY[0]->Value->TrackingResult-UpdateDescription;
print_r($description);
$description = $auth_call->TrackingResults-KeyValueOfstringArrayOfTrackingResultmFAkxlpY[1]->Value->TrackingResult-UpdateDescription;
print_r($description);
你也可以与foreach互动。
我希望这可以帮到你