我有多個陣列,我想特別價值得到使用foreach
我下面的代碼PHP數組如何在數組值獲取使用的foreach
注意:未定義指數:TRANSID在上線52
$test = array(
'messages' => Array
(
'resultCode' => 'Ok',
'message' => Array
(
'code' => 'I00001',
'text' => 'Successful',
),
),
'transactionResponse' => Array
(
'responseCode' => '1',
'authCode' => 'Z7K31J',
'avsResultCode' => 'Y',
'cvvResultCode' => 'P',
'cavvResultCode' => '2',
'transId' => '40004672975',
'refTransID' => Array
(
),
'transHash' => '163382584395AB06470CF365AD6F7381',
'testRequest' => '0',
'accountNumber' => 'XXXX4242',
'accountType' => 'Visa',
'messages' => Array
(
'message' => Array
(
'code' => '1',
'description' => 'This transaction has been approved',
),
),
'transHashSha2' => Array
(
),
),
);
我的陣列上方,在執行的foreach $test
我想的transid
顯示值,response
,transhash
foreach ($test as $key => $value) {
$response = $value['resultCode'];
$transId = $value['transId'];
$authCode = $value['authCode'];
$transHash = $value['transHash'];
}
'$值「transactionResponse」] [「TRANSID」]' – hassan
@Janak維亞斯確實想只是形成第二陣「transactionResponse」 ? –
你不能用你想要的foreach。您在消息數組中沒有transId,authCode或transHash,並且還有transactionResponse數組中的resultCode。 –