Posts Tagged ‘PHP Tutorials’

PHP Even or Odd | PHP Tutorial | PHP Script

Thursday, November 12th, 2009

Here is a great way of determining if a value is even or odd, often times I use this function to color a table of data on every other line old school like the green and white line feed paper of my youth.

if( $i&1 ){ even } else{ odd }
or in a fun one liner like i’ve used it many times

$screen_file .= ( $i&1 ? “\t

\n\t
\n” : “\t

\n\t
\n” );