0

所以我得到的是:这个数组($errors)例如:

'F7000' => 'Undefined Fraud',
'V5000' => 'Undefined System',
'A0000' => 'Undefined Approved',
'V6110' => 'Invalid ProcessRequest Number',
.............etc lots more codes.

现在我正在做一些代码,最后我得到了类似的东西:

$message = $result->ResponseMessage = 'V6110';

现在,我想要做的是向用户显示比 V6110 更充分的消息我该怎么做,所以可以说我得到类似的东西

$message = 'Invalid ProcessRequest Number';
print $message;

这将显示用户 Invalid ProcessRequest Number ?

谢谢

4

5 回答 5

2

PHP 中的所有数组都是所谓的关联数组,因此您可以使用字符串作为数组“索引”:

$error=array('F7000' => 'Undefined Fraud',
              'V5000' => 'Undefined System',
              'A0000' => 'Undefined Approved',
              'V6110' => 'Invalid ProcessRequest Number', '...so on');

$errorNo='V6110';    
$message = $error[$errorNo]; // will return you 'Invalid ProcessRequest Number'
if($message=='')
   $message = "Your Default Error Message";
print $message;
于 2013-03-05T13:58:46.523 回答
1
$errors = array (
    'F7000' => 'Undefined Fraud',
    'V5000' => 'Undefined System',
    'A0000' => 'Undefined Approved',
    'V6110' => 'Invalid ProcessRequest Number',
    ...);
$message = 'V6110';
$message = $errors [$message];
echo $message;
于 2013-03-05T13:58:29.897 回答
0
// show V6110 message
echo $errors['V6110'];
于 2013-03-05T13:58:57.717 回答
0
$errorMsg= $errorArray[$result->ResponseMessage];
于 2013-03-05T13:59:14.830 回答
0

尝试类似的东西

$message = $errors[$result->ResponseMessage];
于 2013-03-05T13:59:44.987 回答