Skip to content

Instantly share code, notes, and snippets.

@govindak
Created September 27, 2018 17:46
Show Gist options
  • Save govindak/5ba2b784d4389c61b4f00260eb964cf2 to your computer and use it in GitHub Desktop.
Save govindak/5ba2b784d4389c61b4f00260eb964cf2 to your computer and use it in GitHub Desktop.
foreach loop odd/even
<?php $counter = "";
foreach ( $columns_values as $columns_value ) {
$counter +=1;
// all my var stuff here
?>
<?php if($counter == 1) { ?>
<div class="columns-wrapper odd">
<!-- HTML here for the first loop -->
</div>
<?php }
// If the second item in the loop
elseif($counter == 2) {
// Reset the counter
$counter = 0;
?>
<div class="columns-wrapper even">
<!-- Other HTML here for the second loop -->
</div>
<?php } //end the elseif $counter ?>
<?php } //end the foreach stuff ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment