1

使用我们提供商的 API,我从 API 调用中获取以下数据:

数据(表示 orderid (1604),然后是订单中的各个项目):

object(stdClass)#395 (1) {  
    ["GetOrderDetailsInfoResult"]=> object(stdClass)#396 (4) {  
        ["RequestID"]=> int(113724)  
        ["Success"]=> int(1)  
        ["Message"]=> string(0) ""  
        ["OrderDetailsResponse"]=> object(stdClass)#397 (1) {  
            ["OrderDetailsResponse"]=> array(2) {  
                [0]=> object(stdClass)#53 (12) {  
                    ["OrderID"]=> int(1604)  
                    ["PartyID"]=> int(0)  
                    ["OrderDetailID"]=> int(805)  
                    ["ProductID"]=> string(3) "B25"  
                    ["Description"]=> string(16) "50 Credits"  
                    ["Quantity"]=> int(1)  
                    ["Price"]=> string(7) "25.0000"  
                    ["Volume"]=> string(7) "25.0000"  
                    ["Tax"]=> string(6) "0.0000"  
                    ["TaxableAmount"]=> string(6) "0.0000"  
                    ["GroupOwner"]=> int(0)  
                    ["ParentOrderDetailID"]=> int(0)  
                }  
                [1]=> object(stdClass)#419 (12) {  
                    ["OrderID"]=> int(1604)  
                    ["PartyID"]=> int(0)  
                    ["OrderDetailID"]=> int(807)  
                    ["ProductID"]=> string(4) "B100"  
                    ["Description"]=> string(17) "200 Credits"  
                    ["Quantity"]=> int(1)  
                    ["Price"]=> string(8) "100.0000"  
                    ["Volume"]=> string(8) "100.0000"  
                    ["Tax"]=> string(6) "0.0000"  
                    ["TaxableAmount"]=> string(6) "0.0000"  
                    ["GroupOwner"]=> int(0)  
                    ["ParentOrderDetailID"]=> int(0)  
                }  
            }  
        }  
    }  
} 

我可以得到尽可能多的 RequestID,但我无法进入订单的值...如何使用 php 直接获取单个项目?

谢谢。

4

1 回答 1

0

这些项目可以像这样迭代:

foreach($data->GetOrderDetailsInfoResult->OrderDetailsResponse->OrderDetailsResponse as $item)
{
    echo $item->ProductID;
    echo $item->Description;
    echo $item->Quantity;
    echo $item->Price;
}
于 2012-12-25T19:46:13.883 回答