Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active June 10, 2020 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/dc0907959cea496f8d98a2f247a94369 to your computer and use it in GitHub Desktop.
Save wplit/dc0907959cea496f8d98a2f247a94369 to your computer and use it in GitHub Desktop.
am I an even post or an odd post?
<?php
global $counter;
if (0 == $counter % 2) {
// do something if an odd post
echo 'an odd post';
} else {
// do something if an even post
echo 'an even post';
}
$counter++;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment