I am fetching the TransactionList through affiliateservice api.
My print_r($response) gives me this (I had to put xx but actually there are numbers there):
stdClass Object
(
[getTransactionListReturn] => Array
(
[0] => stdClass Object
(
[iId] => xx
[sStatus] => pending
[sType] => normal
[sIp] => xx
[bPaid] => xx
[iPaymentId] => xx
[iMerchantId] => xx
[fSaleAmount] => xx
[fCommissionAmount] => xx
[dClickDate] => xx
[dTransactionDate] => xx
[sClickref] => xx
[aTransactionParts] => Array
(
[0] => stdClass Object
(
[sCommissionGroupName] => STANDARD
[fSaleAmount] => xx
[fCommissionAmount] => xx
[iCommission] => xx
[sCommissionType] => percentage
)
)
)
[1] => stdClass Object
(
[iId] => x
[sStatus] => pending
[sType] => normal
[sIp] => x
[bPaid] =>
[iPaymentId] => x
[iMerchantId] => x
[fSaleAmount] => x
[fCommissionAmount] => x
[dClickDate] => x
[dTransactionDate] => x
[sClickref] => x
[sSearchSiteName] => x
[sSearchSiteKeyword] => x
[aTransactionParts] => Array
(
[0] => stdClass Object
(
[sCommissionGroupName] => DEFAULT
[fSaleAmount] => x
[fCommissionAmount] => x
[iCommission] => x
[sCommissionType] => percentage
)
)
)
)
[getTransactionListCountReturn] => stdClass Object
(
[iRowsReturned] => 2
[iRowsAvailable] => 386
)
)
So, my question is how can I “parse” this in PHP? I mean how can I access these data? I mean something like
$response[0]->sStatus;
Thank you for your help!
Everything is an instance of the
stdClass, the standard class in PHP (except for the arrays, of course :)).This means you would use
->to access the properties of each object.You probably got this from using
json_decode(). You can set the second parameter totrueif you’d rather deal with arrays than objects.