从php对象数组中存储一个变量


Store a variable from the array of object php

我有一个php变量$purchase_data当我做

print_r('purchase_data');

我得到的输出是

Array
(
    [downloads] => Array
        (
            [0] => Array
                (
                    [id] => 28
                    [options] => Array
                        (
                        )
                    [quantity] => 1
                )
        )
    [fees] => Array
        (
        )
    [subtotal] => 1
    [discount] => 0
    [tax] => 0
    [price] => 1
    [purchase_key] => a8d14e34ba425f9de6afe3ad4809587e
    [user_email] => esh@test.com
    [date] => 2014-05-11 20:07:22
    [user_info] => Array
        (
            [id] => 1
            [email] => eshtest.com
            [first_name] => esh
            [last_name] => 
            [discount] => none
            [address] => 
        )
    [post_data] => Array
        (
            [edd_email] => esh@test.com
            [edd_first] => esh
            [edd_last] => 
            [edd_phone] => 919995871693
            [edd-user-id] => 1
            [edd_action] => purchase
            [edd-gateway] => sample_gateway
        )
    [cart_details] => Array
        (
            [0] => Array
                (
                    [name] => Shirt
                    [id] => 28
                    [item_number] => Array
                        (
                            [id] => 28
                            [options] => Array
                                (
                                )
                            [quantity] => 1
                        )
                    [item_price] => 1
                    [quantity] => 1
                    [discount] => 0
                    [subtotal] => 1
                    [tax] => 0
                    [price] => 1
                )
        )
    [gateway] => sample_gateway
    [card_info] => Array
        (
            [card_name] => 
            [card_number] => 
            [card_cvc] => 
            [card_exp_month] => 
            [card_exp_year] => 
            [card_address] => 
            [card_address_2] => 
            [card_city] => 
            [card_state] => 
            [card_country] => 
            [card_zip] => 
        )
)

如何将edd_phone [edd_phone]的值存储到变量$mobileNo中?

很抱歉提出这样的问题。但急需帮助

如果你想把[edd_phone]的值赋给$mobileNo,使用:

$mobileNo = $purchase_data['post_data']['edd_phone'];

作为旁注:您的数组嵌套非常复杂。如果我是你,我就避免这样复杂的数组。