0

When I do this :

$this->load->library('mcapi');
$this->load->config('mcapi', TRUE);

// get list members
$retval = $this->mcapi->listMembers('0000000', 'subscribed', null, 0, 5000 );

foreach ($retval as $member) {
    echo $member['email'] . " - " . $member['timestamp'] . "\n";
}

I get this error:

A PHP Error was encountered  
Severity: Notice    
Message: Undefined index: email    
Filename: tabs/mailchimp.php    
Line Number: 18

But When I print the array with print_r(), it works fine.

$retval = $this->CI->mcapi->listMembers('0000000', 'subscribed', null, 0, 5000);
print_r($retval);

I get the data like this:

Array (
    [total] => 2
    [data] => Array (
        [0] => Array (
            [email] => [email protected]
            [timestamp] => 2012-01-06 09:29:31
        ) 
    )
)
0

1 Answer 1

1

You need to do <?php foreach($retval['data'] as $member) { } ?> - the array containing the 'email' key is nested inside the data array.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.