co-authors plugin - inline listing

I'm trying to set up co-authors plugin in order to show articles authors

function inl_users() {
if ( function_exists( 'get_coauthors' ) ) {
  $coauthors = get_coauthors();
  //array_shift($coauthors);
  foreach ( $coauthors as $coauthor ) {
    $autArray[] = 'a href=' . get_author_posts_url( $coauthor-ID ) . '' . $coauthor-display_name . '/a';
    echo implode(, , $autArray);
  }
}

The first author is shown twice in the first element, like this:
for $autArray = (John Smith, Joe Blogs); it returns John SmithJohn Smith, Joe Blogs

full rendered html is like this:

a href=https://example.com/author/john-smith/John Smith/aa href=https://example.com/author/john-smith/John Smith/a, a href=https://example.com/author/joe-blogs/Joe Blogs/a


as you can see I've tried to use array_shift() because I thought they were two distinct elements, but they are not
any suggestions?

thanks in advance

Topic multi-author list-authors author widgets plugins Wordpress

Category Web


solved using for loop instead of foreach:

function inl_users() {
if ( function_exists( 'get_coauthors' ) ) {
  $coauthors = get_coauthors();
  for ($i = 0; $i < count($coauthors); $i++){
      $autArray[] = '<a href=' . get_author_posts_url( $coauthors[$i]->ID ) . '>' . $coauthors[$i]->display_name . '</a>';
  }
  echo implode(", ", $autArray);
}

does anoyone know why?

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.