0

I'm getting the following results from an API call and putting it into a variable called 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 ( )
)

I'm trying to get the ID value and I've tried the following but it doesn't return a value:

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

How can I get the ID?

ThomasVdBerge
  • 7,483
  • 4
  • 44
  • 62
user1048676
  • 9,756
  • 26
  • 83
  • 120

2 Answers2

1

Try to debug your data like this:

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

That way you will see how your data is organized, and you will know how to get the right value.

Kristian Vitozev
  • 5,791
  • 6
  • 36
  • 56
0

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

  • 3
    Why should the OP "try this"? A good answer will always have an explanation of what was done and why it was done that way, not only for the OP but for future visitors to SO. – Jay Blanchard Aug 03 '15 at 20:16