I've written a lot about how probiotics/prebiotics can alter gut bacteria, but clearly food is a primary factor. This is a neat study that tested the potential of cruciferous vegetables (like broccoli) to alter gut flora.
Subjects consumed refined grains with no fruits and vegetables (sounds like the typical American diet!). Then they added only cruciferous vegetables to the diet. Just this addition was enough to alter gut bacteria. The results were individual-specific, but the addition of crucifers did sucessfully alter the balance of gut bacteria in the subjects.
As the old saying goes, everyone should eat their broccoli.