如何在php中显示多维数组数据?

时间:2017-10-06 17:54:20

标签: php arrays multidimensional-array payment-gateway

我为我的网站安装了支付网关(网络在线动态支付集成)..

他们说:

“所有回复都应通过HTTPS POST发布到商家成功”

简单地说我们已经将响应参数定制为二维的阵列

    [text] => The decrypted response string
    [merchantId] => merchantId
    [Transaction_Status_information] => TxnResponseStatus

 ResponseBlockBitMap = merchantId'||'packetBitMap '||'transactionData '||'txnResponse '||'TxnResponseStatus '||'merchantData '||'fraudData '||'DCCData '||'additionalData

 TxnResponseStatus    = FieldBitmap'|'StatusFlag'|'ErrorCode'|'ErrorMessage


Array
(
    [text] => 201607211000001||1110010||111111|1472547260|AED|100.0|CC|VISA|01||1111101|2001608000465536|30-AUG-2016 02:24:53 PM|NOT ENROLLED|Partially Secure|4725473001696358604007|831000||111|SUCCESS|00000|No Error.||11111|YES|88.61|USD|3.75|0.7178203
    [merchantId] => 201607211000001
    [Transaction_Status_information] => 111|SUCCESS|00000|No Error.

 )

并且只能使用以下代码获取“merchantId”

$merchantid=$_POST['merchantId'];

echo $merchantid;

这是他们给出的一些示例代码

/**
* Decrypts data with required decryption algorithm
* @param string $data string which needs to be decrypted            
* @param string $key  key to decrypt data
* @param string $iv   initializes CBC decryption
* @return string      decrypted string
*/
    public function decryptData( $data, $key, $iv ){

        if($data){

            list($merchantId,$encryptString) = explode("||", $data);

            $enc          = $this->encryptMethod;
            $mode         = $this->encryptMode;
            $iv           = $iv;
            $encrypt_key  = $key;

            $EncText      = base64_decode($encryptString);
            $padtext      = mcrypt_decrypt($enc, base64_decode($encrypt_key), $EncText, $mode, $iv);
            $pad          = ord($padtext{strlen($padtext) - 1});    

            $text         = substr($padtext, 0, -1 * $pad); 
            //$reponseParameters = explode("|",$text);
            $reponseArray = explode("||",$text);

            $blockEI             = $reponseArray[0]; // It has to contains Seven indicators
            $bitmapString        = str_split($blockEI);
            $blockEIArrayKey     = array(
                                            'Transaction_Response',                //Same as Request 
                                            'Transaction_related_information',    // Transaction related information 
                                            'Transaction_Status_information',    //  Transaction Status information 
                                            'Merchant_Information',             //   Merchant Information 
                                            'Fraud_Block',                     //    Fraud Block 
                                            'DCC_Block',                      //     DCC Block 
                                            'Additional'                     //      Additional Block Like Card Mask 
                                        );  
            //
            $bit          = 0;
            $blockEIArray = array();

            foreach($blockEIArrayKey as $blockValues){
                $blockEIArray[$blockValues] = $bitmapString[$bit];
                $bit++;
            }
            $blockEIArray = array_filter($blockEIArray);
            // Remove the first element from Array to map with the bit map values 
            array_shift($reponseArray);
            $resposeAssignedArray = array();
            $res                  = 0;
            foreach($blockEIArray as $key => $value){
                    $resposeAssignedArray[$key] =  $reponseArray[$res];
                $res++;
            }
                    $TransactionResposeValue['text']            = $merchantId.'||'.$text;
                    $TransactionResposeValue['merchantId']      = $merchantId;
                    $TransactionResposeValue['DataBlockBitmap'] = $blockEI;
            foreach($blockEIArrayKey as $key => $value){
                    if(isset($resposeAssignedArray[$value]))
                        $TransactionResposeValue[$value] = $resposeAssignedArray[$value];
                    else
                        $TransactionResposeValue[$value] = 'NULL';
            }

            return $TransactionResposeValue;        

        }else{
            return false;
        }

    }   

如何访问其他值呢?提前谢谢

0 个答案:

没有答案