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] => [email protected] [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] => [email protected] [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?

1
  • $listid['data'][0]['id']? Commented Aug 3, 2015 at 20:18

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.