<?php if( get_field('degrees') ) {
while ( have_rows('degrees') ) : the_row();
if (!get_sub_field('degree_aftername')) {
continue;
}
$array[] = get_sub_field('degree_select');
endwhile;
$foo = implode(', ', array_column($array, 'label'));
echo '<span class"">, ' . $foo . '</span>';
}
?>