在数组项之间添加逗号除了last(wordpress)

I'm trying to list authors for a certain category on Wordpress and I'm having trouble inserting a comma between each item, except for the last. Here's my code:

<?php
 if (is_category() || is_tag()) {
  $at_least = 1;
  $author_array = list_author_in_this_cat ($at_least);
  foreach (array_slice($author_array, 0, 10) as $author):
   $name = get_userdata($author)->display_name;
   $link = get_userdata($author)->user_login;
   echo "<a href='/author/".$link."'>".$name."";
  endforeach;
 }
?>

Try this:

$nameArray = array();
foreach (array_slice($author_array, 0, 10) as $author):
    $name = get_userdata($author)->display_name;
    $link = get_userdata($author)->user_login;
    $nameArray[] = "<a href='/author/".$link."'>".$name."";
endforeach;

echo implode(',', $nameArray);

This will put each author entry into an array; when you echo it out, you're merging the array using commas as the glue.