我有以下对象。在这种情况下,如何将GrossAmount (1.10)的值作为变量获取?
我试过了:
$gross = $object->GrossAmount->_; 而$id = $object->GrossAmount->currencyID;
为我提供了GBP的当前代码
但这不管用。
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
)发布于 2013-03-01 02:37:43
嗯,你的顶级对象是一个数组,而不是一个对象。因此,您应该使用$object['GrossAmount']->_来访问该字段。
发布于 2013-03-01 02:44:15
简单地做
$object->GrossAmount->{'_'}发布于 2013-03-01 02:37:43
您可以尝试使用
$gross = $object->GrossAmount->{"_"};https://stackoverflow.com/questions/15143044
复制相似问题