here is somthing i use in laravel,
this will search the list for the member ,if found it will update his info (in this case his email) else it will create a new one.
public function update_subscribe($old_email, $new_email, $user)
{
$found = MailchimpWrapper::helper()->searchMembers($old_email, $list_id);
extract($found);
if ($exact_matches['total'] == 1)
{
return MailchimpWrapper::lists()->updateMember(
$list_id,
['email' => $old_email],
['new-email' => $new_email],
'html',
false
);
}
return $this->add_subscribe($user);
}
check https://apidocs.mailchimp.com/api/2.0/helper/search-members.php , https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php , https://apidocs.mailchimp.com/api/2.0/lists/update-member.php