PHP数组传递给函数

时间:2016-06-08 10:20:13

标签: php arrays

我使用此函数来传递细节,我通过直接传递预定义的数组来测试它,但是当我在函数中访问数组时,一切都返回NULL,而不是我设置的值。

$this->send_member_email($order=array(
                                    'order_name' => 'D',
                                    'billing_firstname' => 'D',
                                    'billing_lastname' =>  'mcc',
                                    'billing_email' => 'd@test.com',
                                    'billing_address' => 'd',
                                    'billing_city' => 'al',
                                    'billing_postcode' => 'c i',
                            ), "d@test.com", true);

然后我在这里访问它:

$member_data = array(
                    'member_no' => $membership_no,
                    'member_firstname' => $order->billing_firstname,
                    'member_secondname' => $order->billing_lastname,
                    'member_address' => $order->billing_address,
                    'member_city' => $order->billing_city,
                    'member_postcode' => $order->billing_postcode,
                    'member_country' => $order->billing_country,
                    'member_timestamp' => gm_time('datetime'),
            );

我是否错误地格式化了数组,或者代表我忽略了它。任何帮助将不胜感激。

编辑:

这是它作为值记录到db:

VALUES ('fd310a396f8c9', NULL, NULL, NULL, NULL, NULL, NULL, '2016-06-08 11:10:36')

2 个答案:

答案 0 :(得分:1)

试试这个

$member_data = array(
                'member_no' => $membership_no,
                'member_firstname' => $order['billing_firstname'],
                'member_secondname' => $order['billing_lastname'],
                'member_address' => $order['billing_address'],
                'member_city' => $order['billing_city'],
                'member_postcode' => $order['billing_postcode'],
                'member_country' => $order['billing_country'],
                'member_timestamp' => gm_time('datetime'),
        );

答案 1 :(得分:0)

使用$order['billing_firstname']