我有一个如下所示的数组:
Array (
[TIMESTAMP] => 2012-01-04T21:36:32Z
[CORRELATIONID] => 4564e64d7f75f
[ACK] => Failure
[VERSION] => 51.0
[BUILD] => 2278658
[L_ERRORCODE0] => 10764
[L_SHORTMESSAGE0] => This transaction cannot be processed at this time. Please try again later.
[L_LONGMESSAGE0] => This transaction cannot be processed at this time. Please try again later.
[L_SEVERITYCODE0] => Error
[L_ERRORPARAMID0] => ProcessorResponse
[L_ERRORPARAMVALUE0] => PPAV
[AMT] => 25.00
[CURRENCYCODE] => USD
[AVSCODE] => N
[CVV2MATCH] => M
)
如果我想要回显[L_LONGMESSAGE0]的值(这是'此交易此时无法处理。请稍后再试'),我将如何使用php执行此操作?
更清楚的是,当我使用此命令时,我从PayPal获取此数组: urldecode(print_r($ httpParsedResponseAr,true))
因此,假设该命令产生上面显示的数组,我将如何回显[L_LONGMESSAGE0]?
提前感谢您的帮助
答案 0 :(得分:2)
假设:此数组位于$arr
变量内。
echo $arr['L_LONGMESSAGE0'];
答案 1 :(得分:1)
echo $myarray["L_LONGMESSAGE0"]
答案 2 :(得分:1)
如果你的数组存储在变量$ response中,你可以
echo $response["L_LONGMESSAGE0"];
答案 3 :(得分:0)
有点偏离主题,但我希望你不会向买家提供这些信息? API错误响应应由您(商家)解释,并向买方显示更友好的消息 至少,您可以进行简单的切换;
switch ($httpParsedResponseAr['L_ERRORCODE0']) {
case "10764":
echo "Unable to process your transaction. Please try a different payment method.";
break;
case "10002":
echo "Unexpected error. Please try again in an hour.";
// Log error
error_log("10002 error in site",1,"operator@example.com");
break;
case "10001":
echo "Unexpected error from PayPal. Our engineers have been notified.";
error_log("10001 in site",1,"operator@example.com");
break;
}