Array terms, if term one, if term two, etc

I solved it like this. Although if there are more than 3 co-authors problems could arise

$tagx = get_the_terms($post->ID , 'autoria');
            $number = count($tagx);
           
             if ( $number == 1) {
             $first_author = $tagx[0];
                    echo '<strong>'; echo esc_html( $first_author->name ); echo '</strong>';
                
            }

            if ($number == 2) {
            $first_author = $tagx[0];
            $second_author = $tagx[1];    
                
            echo '<strong>'; echo esc_html( $first_author->name ); echo '</strong>,'; 
            echo ' <strong>';
            echo explode(' ', $second_author->name)[3] . ' ';
            echo explode(' ', $second_author->name)[2] . ' ';
            echo explode(' ', $second_author->name)[1] . ' ';
            echo explode(' ', $second_author->name)[0] . ' ';
            echo '</strong> ';
                
            }


            if ( $number > 2) {
            $first_author = $tagx[0];

            echo '<strong>'; echo esc_html( $first_author->name ); echo '</strong>, ';
            

            foreach ($tagx as $tag) {
            $tag_array[] = $tag->name;

                if ($tag_array[1]) {

                    echo ', <strong>';
                    echo explode(' ', $tag->name)[3] . ' ';
                    echo explode(' ', $tag->name)[2] . ' ';
                    echo explode(' ', $tag->name)[1] . ' ';
                    echo explode(' ', $tag->name)[0] . ' ';
                    echo '</strong> ';
                    
                    }
                if ($tag_array[2]) {

                    echo 'y <strong>';
                    echo explode(' ', $tag->name)[3] . ' ';
                    echo explode(' ', $tag->name)[2] . ' ';
                    echo explode(' ', $tag->name)[1] . ' ';
                    echo explode(' ', $tag->name)[0] . ' ';
                    echo '</strong> ';
                    
                    } 
                }
            }

deneme bonusudeneme bonusu veren sitelerOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino