PHP Even or Odd | PHP Tutorial | PHP Script

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” );

Tags: , ,

Comments are closed.