Q: Skip a line in foreach loop I have created a slider to display a list of basketball games. I've got it working and it looks like this on my website currently:

I'm using the following foreach loop to display the data.
    <?php 
    
    uasort($json['response']['data'], function ($a, $b) {
        if ($a['matchTime']==$b['matchTime']) return 0;
        return $a['matchTime']>$b['matchTime'] ? 1 : -1;
        });

    foreach($json['response']['data'] as $item) {
        if ($item['competitionName'] == 'Junior SS Premiership Zone 3' ) {
            continue;}
        if ($item['competitionName'] == 'CSW Division 1' ) {
        continue;}
        if ($item['competitionName'] == 'Season Showdown 19' ) {
        continue;}
        if ($item['competitionName'] == 'SS19 Challengers' ) {
        continue;}
        if ($item['competitionName'] == 'SS20 Challengers' ) {
        continue;}
        if ($item['competitionName'] == 'SS20 Pre-Season' ) {
        continue;}
        if ($item['competitionName'] == 'Schick AA Zone 3 Premierships' ) {
        continue;}
        if ($item['competitionName'] == 'New World Series 2018' ) {
        continue;}
        if ($item['competitionName'] == 'SS18 Challengers' ) {
        continue;}
    
        print'
        
        <li class="item">
                        <a class="item-link" href="/schedule">
                            <div class="game-meta game-date date-format">
                                <span class="date-month">'; $matchtime = $item['matchTime']; echo date('M', strtotime($matchtime)); print'</span>'; $matchtime = $item['matchTime']; echo date('j', strtotime($matchtime));
                            print '</div>';
                            
                            foreach ($item["competitors"] as $teams){
                            
                            print '
                            <div class="game-meta game-team">
                                <img class="game-team__logo game-team__logo-tc" alt="Tawa" src="https://summerseries.nz/wp-content/themes/SS/logos/'; echo $teams['teamCode']; print '.svg">
                                <div class="game-team__abbrev">'; echo $teams['teamCode']; print'</div>
                            </div>
                            <div class="game-meta game-vs">vs</div>';
                            
                            };
                            
                           print ' <div class="game-time">'; $matchtime = $item['matchTime']; echo date('g:i A', strtotime($matchtime)); print'</div>
                        </a>
                    </li>';


    
} ?>

It functions fine. I get the data, but my foreach loop shows the <div class="game-meta game-vs">vs</div> twice which a foreach is supposed to do. I want to remove that so it only shows in the middle. Right now the image shows TEAM vs TEAM vs which it should only show TEAM vs TEAM.
Any way to do this? I've tried making it a variable under continue but it didn't like it.
Thanks!

A: glad to Help!
It seems that only two teams are gaming, so just change the code FROM:
                            foreach ($item["competitors"] as $teams){
                            print '
                            <div class="game-meta game-team">
                                <img class="game-team__logo game-team__logo-tc" alt="Tawa" src="https://summerseries.nz/wp-content/themes/SS/logos/'; echo $teams['teamCode']; print '.svg">
                                <div class="game-team__abbrev">'; echo $teams['teamCode']; print'</div>
                            </div>
                            <div class="game-meta game-vs">vs</div>';
                            
                            };

TO:
                            print '
                            <div class="game-meta game-team">
                                <img class="game-team__logo game-team__logo-tc" alt="Tawa" src="https://summerseries.nz/wp-content/themes/SS/logos/'; echo $item["competitors"][0]['teamCode']; print '.svg">
                                <div class="game-team__abbrev">'; echo $item["competitors"][0]['teamCode']; print'</div>
                            </div>
                            <div class="game-meta game-vs">vs</div>';
                            print '
                            <div class="game-meta game-team">
                                <img class="game-team__logo game-team__logo-tc" alt="Tawa" src="https://summerseries.nz/wp-content/themes/SS/logos/'; echo $item["competitors"][1]['teamCode']; print '.svg">
                                <div class="game-team__abbrev">'; echo $item["competitors"][1]['teamCode']; print'</div>
                            </div>';

If there's more than 2 teams gaming, Please tell me and i'll change a solution
Wish you a good day~

A: Count how many times you've gone through the loop, and only print the "vs" <div> if you're not at the last iteration:
$i = 0; // How many teams we've printed so far

foreach ($item["competitors"] as $teams){
    print '
        <div class="game-meta game-team">
          <img class="game-team__logo game-team__logo-tc" alt="Tawa" src="https://summerseries.nz/wp-content/themes/SS/logos/'; echo $teams['teamCode']; print '.svg">
          <div class="game-team__abbrev">'; echo $teams['teamCode']; print'</div>
        </div>
  ';

  if ( ++$i < sizeof($item["competitors"]) ) {
    print '
        <div class="game-meta game-vs">vs</div>
    ';
  }
}

