In Genesis 41, Pharaoh had two dreams that troubled him. In the first dream, seven fat, healthy cows came up from the Nile and grazed in the meadow, then seven thin, gaunt cows came up and devoured the fat cows. In the second dream, seven plump, good ears of grain grew on a single stalk, then seven thin ears, scorched by the east wind, sprouted and swallowed the good ears.
When none of Pharaoh's magicians could interpret the dreams, Joseph was summoned from prison. Joseph explained that both dreams carried the same message: seven years of great abundance would come upon the land of Egypt, followed by seven years of severe famine. The famine would be so devastating that the years of plenty would be forgotten. Joseph advised Pharaoh to appoint a wise administrator to store grain during the abundant years to sustain Egypt through the famine.
Pharaoh was so impressed that he appointed Joseph himself to oversee this plan, making him second-in-command over all Egypt (Genesis 41:39-43). The other options - seven months of war, seven cities destroyed, and seven days of harvest - are not found in the biblical text and do not correspond to any part of Pharaoh's dreams.