mahers solution was a good one.
I'd like to offer an alternative solution that I've used that works well.
$data = array('ABCD','efgh','IJKL','mnop','QRSTu','VwxYZ','1234','56','78','9');
$bgcolors = array("#F0F0F0","#FFFFFF");
$colors = count($bgcolors);
$counter = 1;
print "<table border=1>\n";
foreach($data as $item){
print "<tr bgcolor=\"" . $bgcolors[$counter%$colors] . "\"><td>" . $item . "</td></tr>\n";
$counter++;
}//end foreach
print "</table>\n";
I like doing it this way because I can add any # of colors to the bgcolors array and not have to modify anything else. So if I want alternating colored rows of red,white,blue, I can easily make that change.
One other use I've found is styles. Instead of just specifying a background color, I can set the class of each row to a predefined style name. the array bgcolors would then be $styles = array('style1','style2');
and the table row would have class= instead of bgcolor=
just a thought. I have them once in a while.