Swapping between two div classes in foreach

  php, variables

I am currently coding a page based on a json query.

Here is a snippet of the code, I don’t want to give the top half as that is grabbing the remote json with id’s and passwords, but here is the main snippet:

$content_size = 'one_half';

foreach ( $json_decoded['fixtures-results']['matches'] as $match ){

function display_match($match){
global $content_size; 
if (strtotime($match['date']) < time()) { goto skip; }
$home_team_name = strtolower($match['home-team']['name']);
$home_team_name = preg_replace('/s+/', '_',$home_team_name);

$away_team_name = strtolower($match['away-team']['name']);
$away_team_name = preg_replace('/s+/', '_',$away_team_name);
$match_date = date("M jS, Y", strtotime($match['date']));
echo '<div class="'.$content_size.'">';
echo '<div class="latest_results" style="background:#ffffff">';
echo '<h6>'.$match_date.', '.$match['status']['full'].'</h6>';
echo '<div class="latest_results_col"><img src="/team_logos/'.$home_team_name.'.png"><span>'.$match['home-team']['name'].'</span></div>';
echo '<div class="latest_results_col goalscore2">vs</div>';
echo '<div class="latest_results_col"><img src="/team_logos/'.$away_team_name.'.png"><span>'.$match['away-team']['name'].'</span></div>';
echo '<div class="clear">';
echo '<span>Location:'.$match['venue'].'</span>';
echo '</div>';
echo '</div>';
echo '</div>';
if ($content_size == "one_half") { $content_size = "one_half_last"; goto skip; }else{ $content_size = "one_half"; goto skip; }

What i want is the first div class to be one_half then the next one as one_half_last then back to one_half and so on.

The result is the first div has the class one_half but the second has no class, then the third has one_half and so on, so you see it seems to be working, except its missing the second, fourth, sixth ect class.

Any help would be greatly received.

Kind Regards,

Source: Ask PHP