In our company phonebook we print out the fields in groups of 1 through 6 in gray bars (i.e. it's variable based on user preference.)
Since I don't know ahead of time how many there will be and didn't want to program up a different function for each, here's the code we use to tell if we should be gray or not:
function is_gray($num,$grayspace){
$gb=$grayspace*2;
if ($num%$gb>=0&&$num%$gb<$gb/2) return 1;
}