Date: 04/11/07 (PHP Community) Keywords: php, database I had a big long report that I printed to the screen. It was a foreach loop that went through an associative array of database results and put them in a table. It looked crappy at first. This is what I had at the beginning: As you can see it was pretty simple, and as you can imagine very plain. I needed to number the list.foreach($foo as $a => $b) That took care of the numbered rows. I thought that it would be easier to use if every other row was a diff. color. I first tried to use modulus to get the remainder of $i when divided by 2. If there was a remainder, then that row was odd. That was my thinking - but it didn't work. I found this solution (that was easy) on php.net.$i = 0; Works like a charm :D$i = 0;
|