0

我有以下对象。在这种情况下,如何将 GrossAmount (1.10) 的值作为变量?

我试过了:

$gross = $object->GrossAmount->_; 

然而$id = $object->GrossAmount->currencyID;

是否给了我当前的英镑代码

但这行不通。

Array
(
    [TransactionID] => 9BBXH1113VA716445A
    [ParentTransactionID] => 
    [ReceiptID] => 
    [TransactionType] => express-checkout
    [PaymentType] => instant
    [PaymentDate] => 2013-02-28T18:26:43Z
    [GrossAmount] => stdClass Object
        (
            [_] => 1.10
            [currencyID] => GBP
        )

    [FeeAmount] => stdClass Object
        (
            [_] => 0.21
            [currencyID] => GBP
        )

    [TaxAmount] => stdClass Object
        (
            [_] => 0.00
            [currencyID] => GBP
        )

    [ExchangeRate] => 
    [PaymentStatus] => Completed
    [PendingReason] => none
    [ReasonCode] => none
)
4

3 回答 3

2

嗯,您的顶级对象是一个数组,而不是一个对象。因此,您应该使用$object['GrossAmount']->_来访问该字段。

于 2013-02-28T18:37:43.053 回答
0

简单地做

$object->GrossAmount->{'_'}
于 2013-02-28T18:44:15.420 回答
-1

你可以试试

$gross = $object->GrossAmount->{"_"};
于 2013-02-28T18:37:43.420 回答