PHP Modulo Operator For Alternating Rows

Alternating row colours within a grid of data can make for a more pleasant viewing experience and has become a popular styling method in recent times. I was a little incredulous at some code I saw recently to determine alternating rows so without further introduction, meet the Modulo operator which is a quick and easy way to get up and running:

for($i=0;$i<10;$i++){ if($i % 2){ // This is an even row }else{ // This is an odd row } }

I'm sure you will be able to apply this to your own css or styling within your loops.