Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我能';无法访问此数组元素_Php_Arrays - Fatal编程技术网

Php 为什么我能';无法访问此数组元素

Php 为什么我能';无法访问此数组元素,php,arrays,Php,Arrays,这是2co的多个数组,我正在尝试获取返回值并通过电子邮件发送给管理员,但我无法访问此数组中的值 <?php require_once 'payment-api/Twocheckout.php'; Twocheckout::privateKey('4D67BA12-CE09-4F1D-AB20-0133F24E3472'); Twocheckout::sellerId('901249656'); Twocheckout::sandbox(true); try { $charge

这是2co的多个数组,我正在尝试获取返回值并通过电子邮件发送给管理员,但我无法访问此数组中的值

<?php
require_once 'payment-api/Twocheckout.php';

Twocheckout::privateKey('4D67BA12-CE09-4F1D-AB20-0133F24E3472');
Twocheckout::sellerId('901249656');
Twocheckout::sandbox(true);

try {
    $charge = Twocheckout_Charge::auth(array(
        "merchantOrderId" => "123",
        "token" => $_POST['token'],
        "currency" => 'USD',
        "total" => '10.00',
        "billingAddr" => array(
            "name" => 'Testing Tester',
            "addrLine1" => '123 Test St',
            "city" => 'Columbus',
            "state" => 'OH',
            "zipCode" => '43123',
            "country" => 'USA',
            "email" => 'example@2co.com',
            "phoneNumber" => '555-555-5555'
        )
    ));

    if ($charge['response']['responseCode'] == 'APPROVED') {
        echo "Thanks for your Order!";
        echo "<h3>Return Parameters:</h3>";
        echo "<pre>";
        echo "His name" . $charge['billingAddr']['name'];
        echo "</pre>";
    }
} catch (Twocheckout_Error $e) {
    print_r($e->getMessage());
}
我在这里做错了什么

我从
print\r($charge)获得的信息

使用:


您忘记访问
响应
键。

您从这个回音中得到了什么?如果不知道
twoocheckout\u Charge::auth的功能,很难说。选中
var\u dump($charge)
您可能会看到问题。首先,请参阅print\u r($charge);好的,我编辑我的问题,看看当我
print\r($charge)时我得到了什么是什么阻止您在打印后自己找出答案?我认为这是显而易见的。
echo "His name" . $charge['billingAddr']['name'];
Array
(
    [validationErrors] => 
    [exception] => 
    [response] => Array
        (
            [type] => AuthResponse
            [currencyCode] => USD
            [shippingAddr] => Array
                (
                    [addrLine1] => 
                    [addrLine2] => 
                    [city] => 
                    [zipCode] => 
                    [phoneNumber] => 
                    [phoneExtension] => 
                    [email] => 
                    [name] => 
                    [state] => 
                    [country] => 
                )

            [merchantOrderId] => 123
            [orderNumber] => 9093719883561
            [transactionId] => 9093719883582
            [billingAddr] => Array
                (
                    [addrLine1] => 123 Test St
                    [addrLine2] => 
                    [city] => Columbus
                    [zipCode] => 43123
                    [phoneNumber] => 555-555-5555
                    [phoneExtension] => 
                    [email] => example@2co.com
                    [name] => Testing Tester
                    [state] => OH
                    [country] => USA
                )

            [lineItems] => Array
                (
                    [0] => Array
                        (
                            [duration] => 
                            [options] => Array
                                (
                                )

                            [description] => 
                            [price] => 10.00
                            [quantity] => 1
                            [recurrence] => 
                            [startupFee] => 
                            [productId] => 
                            [tangible] => N
                            [name] => 123
                            [type] => product
                        )

                )

            [recurrentInstallmentId] => 
            [responseMsg] => Successfully authorized the provided credit card
            [responseCode] => APPROVED
            [total] => 10.00
            [errors] => 
        )

)
$charge['response']['billingAddr']['name'];