I'm trying to store a list of user emails in array to be used in an API call. Here is my current code:
function getPlayerEmailsByFolderId($userId){
  $args = array(
    'role'        => 'subscriber',
    'meta_key'      => 'player_team_id',
    'meta_value'    => $userId
  );
  $players = new WP_User_Query( $args );
  $contactList = array();
  if ( ! empty( $players->results ) ) {
    foreach ($players->results as $player) {
      $player_email = $player->user_email;
      $contactList[] = array(
          'email'=> $player_email;
      );
    }
  }
  return $contactList;
}
//Get all players on a team via the coach's ID
$emails = getPlayerEmailsByFolderId($userId);
The $contactList[] = array(......); inside the foreach loop is what's causing my code to break, but I can't figure out why. Is my syntax bad?
 
    