Created
September 27, 2018 17:46
-
-
Save govindak/5ba2b784d4389c61b4f00260eb964cf2 to your computer and use it in GitHub Desktop.
foreach loop odd/even
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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