获取多维数组的值

时间:2015-08-03 20:14:41

标签: php arrays

我从API调用中获取以下结果并将其放入名为listid的变量中:

Array ( 
    [total] => 1 
    [data] => Array ( 
        [0] => Array ( 
            [id] => 4960b0d958 
            [web_id] => 182605 
            [name] => School Soccer News & Notifications 
            [date_created] => 2015-08-03 19:34:30 
            [email_type_option] => 
            [use_awesomebar] => 1 
            [default_from_name] => website.com Soccer 
            [default_from_email] => website@website.com 
            [default_subject] => 
            [default_language] => en 
            [list_rating] => 0 
            [subscribe_url_short] => http://eepurl.com/bu3op1 
            [subscribe_url_long] => http://BoostMyTeam.us11.list-manage.com/subscribe?u=sadf&id=4960b0d958 
            [beamer_address] => us11-dbf06a437c-dsdsda@inbound.mailchimp.com 
            [visibility] => pub 
            [stats] => Array ( 
                [member_count] => 1 
                [unsubscribe_count] => 0 
                [cleaned_count] => 0 
                [member_count_since_send] => 1 
                [unsubscribe_count_since_send] => 0 
                [cleaned_count_since_send] => 0 
                [campaign_count] => 0 
                [grouping_count] => 0 
                [group_count] => 0 
                [merge_var_count] => 2 
                [avg_sub_rate] => 0 
                [avg_unsub_rate] => 0 
                [target_sub_rate] => 0 
                [open_rate] => 0 
                [click_rate] => 0 
                [date_last_campaign] => 
            ) 
            [modules] => Array ( ) 
        ) 
    ) 
    [errors] => Array ( )
)

我试图获取ID值,但我尝试了以下内容,但它没有返回值:

echo $listid['data']['id'];

我如何获得身份证?

2 个答案:

答案 0 :(得分:1)

尝试调试您的数据:

echo '<pre>' . print_r($listid, true) . '</pre>';

通过这种方式,您将了解数据的组织方式,并了解如何获得正确的价值。

答案 1 :(得分:0)

尝试echo $listid['data'][0]['id'];