Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created August 26, 2013 14:55
Show Gist options
  • Save phpfiddle/6342312 to your computer and use it in GitHub Desktop.
Save phpfiddle/6342312 to your computer and use it in GitHub Desktop.
Demonstrating every 3rd post.
<?php
$array = array(
'red',
'orange',
'blue',
'green',
'yellow',
'purple',
'white',
'black',
);
echo '<ul>';
$count = 0;
while (list($key, $color) = each ($array)):
$count++;
echo '<li>'. $color . '</li>';
$skip = 2; //Set this line to display something every X item.
if($count %$skip == 0){
echo '<li>Every ' .$skip. ' colors, this line executes.</li>';
}
endwhile;
echo '</ul>'
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment