Documentation

Light-weight, fast, simple and powerful!
 
Translations of this page?:

odd_even()

This simple function returns either “odd” or “even” (in that order) in turn. This helps especially in the production of tables, or in any case where alternating values need to be produced.

For example, used in a foreach loop of this kind (note the “class” in the paragraph tag):

<?php foreach ($articles as $article): ?>
  <p class="<?php echo odd_even(); ?>"><?php echo $article->title(); ?></p>
<?php endforeach; ?>

the odd_even() function would produce this output:

<p class="odd">Yesterday</p>
<p class="even">Penny Lane</p>
<p class="odd">Help!</p>
<p class="even">Eleanor Rigby</p>
...

This function has an alias as even_odd() which produces identical output.

 
functions/odd_even.txt · Last modified: 2012-11-13 10:53 by David
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside